Skip to content

Commit 86e4dd5

Browse files
committed
sh: support for platforms without PIO.
This extends some of the existing special casing for HAS_IOPORT platforms and gets it to the point where platforms can begin to conditionally select it. The major changes here are that the PIO routines themselves go away completely, including all of the machvec port mapping wrappers. With this in place it's possible for any non-machvec abusing platform to disable PIO completely. At present this is left as an opt-in until the abusers are the odd ones out instead of the majority. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent 1c98347 commit 86e4dd5

8 files changed

Lines changed: 54 additions & 34 deletions

File tree

‎arch/sh/Kconfig‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ config SUPERH
99
def_bool y
1010
select EMBEDDED
1111
select HAVE_CLK
12-
select HAVE_IDE
12+
select HAVE_IDE if HAS_IOPORT
1313
select HAVE_LMB
1414
select HAVE_OPROFILE
1515
select HAVE_GENERIC_DMA_COHERENT
@@ -174,6 +174,9 @@ config ARCH_HAS_DEFAULT_IDLE
174174
config ARCH_HAS_CPU_IDLE_WAIT
175175
def_bool y
176176

177+
config NO_IOPORT
178+
bool
179+
177180
config IO_TRAPPED
178181
bool
179182

‎arch/sh/include/asm/io.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#include <asm/io_generic.h>
4040
#include <asm/io_trapped.h>
4141

42+
#ifdef CONFIG_HAS_IOPORT
43+
4244
#define inb(p) sh_mv.mv_inb((p))
4345
#define inw(p) sh_mv.mv_inw((p))
4446
#define inl(p) sh_mv.mv_inl((p))
@@ -60,6 +62,8 @@
6062
#define outsw(p,b,c) sh_mv.mv_outsw((p), (b), (c))
6163
#define outsl(p,b,c) sh_mv.mv_outsl((p), (b), (c))
6264

65+
#endif
66+
6367
#define __raw_writeb(v,a) (__chk_io_ptr(a), *(volatile u8 __force *)(a) = (v))
6468
#define __raw_writew(v,a) (__chk_io_ptr(a), *(volatile u16 __force *)(a) = (v))
6569
#define __raw_writel(v,a) (__chk_io_ptr(a), *(volatile u32 __force *)(a) = (v))
@@ -240,6 +244,8 @@ __BUILD_MEMORY_STRING(q, u64)
240244

241245
#define IO_SPACE_LIMIT 0xffffffff
242246

247+
#ifdef CONFIG_HAS_IOPORT
248+
243249
/*
244250
* This function provides a method for the generic case where a
245251
* board-specific ioport_map simply needs to return the port + some
@@ -255,6 +261,8 @@ static inline void __set_io_port_base(unsigned long pbase)
255261

256262
#define __ioport_map(p, n) sh_mv.mv_ioport_map((p), (n))
257263

264+
#endif
265+
258266
/* We really want to try and get these to memcpy etc */
259267
void memcpy_fromio(void *, const volatile void __iomem *, unsigned long);
260268
void memcpy_toio(volatile void __iomem *, const void *, unsigned long);

‎arch/sh/include/asm/machvec.h‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ struct sh_machine_vector {
1919
const char *mv_name;
2020
int mv_nr_irqs;
2121

22+
int (*mv_irq_demux)(int irq);
23+
void (*mv_init_irq)(void);
24+
25+
#ifdef CONFIG_HAS_IOPORT
2226
u8 (*mv_inb)(unsigned long);
2327
u16 (*mv_inw)(unsigned long);
2428
u32 (*mv_inl)(unsigned long);
@@ -40,12 +44,9 @@ struct sh_machine_vector {
4044
void (*mv_outsw)(unsigned long, const void *src, unsigned long count);
4145
void (*mv_outsl)(unsigned long, const void *src, unsigned long count);
4246

43-
int (*mv_irq_demux)(int irq);
44-
45-
void (*mv_init_irq)(void);
46-
4747
void __iomem *(*mv_ioport_map)(unsigned long port, unsigned int size);
4848
void (*mv_ioport_unmap)(void __iomem *);
49+
#endif
4950

5051
int (*mv_clk_init)(void);
5152
int (*mv_mode_pins)(void);

‎arch/sh/kernel/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ endif
1212
CFLAGS_REMOVE_return_address.o = -pg
1313

1414
obj-y := clkdev.o debugtraps.o dma-nommu.o dumpstack.o \
15-
idle.o io.o io_generic.o irq.o \
15+
idle.o io.o irq.o \
1616
irq_$(BITS).o machvec.o nmi_debug.o process.o \
1717
process_$(BITS).o ptrace_$(BITS).o \
1818
reboot.o return_address.o \
@@ -39,6 +39,7 @@ obj-$(CONFIG_DUMP_CODE) += disassemble.o
3939
obj-$(CONFIG_HIBERNATION) += swsusp.o
4040
obj-$(CONFIG_DWARF_UNWINDER) += dwarf.o
4141
obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_callchain.o
42+
obj-$(CONFIG_HAS_IOPORT) += io_generic.o
4243

4344
obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
4445
obj-$(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST) += localtimer.o

‎arch/sh/kernel/io.c‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,3 @@ void memset_io(volatile void __iomem *dst, int c, unsigned long count)
112112
}
113113
}
114114
EXPORT_SYMBOL(memset_io);
115-
116-
#ifndef CONFIG_GENERIC_IOMAP
117-
118-
void __iomem *ioport_map(unsigned long port, unsigned int nr)
119-
{
120-
void __iomem *ret;
121-
122-
ret = __ioport_map_trapped(port, nr);
123-
if (ret)
124-
return ret;
125-
126-
return __ioport_map(port, nr);
127-
}
128-
EXPORT_SYMBOL(ioport_map);
129-
130-
void ioport_unmap(void __iomem *addr)
131-
{
132-
sh_mv.mv_ioport_unmap(addr);
133-
}
134-
EXPORT_SYMBOL(ioport_unmap);
135-
136-
#endif /* CONFIG_GENERIC_IOMAP */

‎arch/sh/kernel/io_generic.c‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,23 @@ void __iomem *generic_ioport_map(unsigned long addr, unsigned int size)
158158
void generic_ioport_unmap(void __iomem *addr)
159159
{
160160
}
161+
162+
#ifndef CONFIG_GENERIC_IOMAP
163+
void __iomem *ioport_map(unsigned long port, unsigned int nr)
164+
{
165+
void __iomem *ret;
166+
167+
ret = __ioport_map_trapped(port, nr);
168+
if (ret)
169+
return ret;
170+
171+
return __ioport_map(port, nr);
172+
}
173+
EXPORT_SYMBOL(ioport_map);
174+
175+
void ioport_unmap(void __iomem *addr)
176+
{
177+
sh_mv.mv_ioport_unmap(addr);
178+
}
179+
EXPORT_SYMBOL(ioport_unmap);
180+
#endif /* CONFIG_GENERIC_IOMAP */

‎arch/sh/kernel/io_trapped.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,14 @@ int register_trapped_io(struct trapped_io *tiop)
9191
tiop->magic = IO_TRAPPED_MAGIC;
9292
INIT_LIST_HEAD(&tiop->list);
9393
spin_lock_irq(&trapped_lock);
94+
#ifdef CONFIG_HAS_IOPORT
9495
if (flags & IORESOURCE_IO)
9596
list_add(&tiop->list, &trapped_io);
97+
#endif
98+
#ifdef CONFIG_HAS_IOMEM
9699
if (flags & IORESOURCE_MEM)
97100
list_add(&tiop->list, &trapped_mem);
101+
#endif
98102
spin_unlock_irq(&trapped_lock);
99103

100104
return 0;

‎arch/sh/kernel/machvec.c‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ void __init sh_mv_setup(void)
118118
sh_mv.mv_##elem = generic_##elem; \
119119
} while (0)
120120

121+
#ifdef CONFIG_HAS_IOPORT
122+
123+
#ifdef P2SEG
124+
__set_io_port_base(P2SEG);
125+
#else
126+
__set_io_port_base(0);
127+
#endif
128+
121129
mv_set(inb); mv_set(inw); mv_set(inl);
122130
mv_set(outb); mv_set(outw); mv_set(outl);
123131

@@ -129,16 +137,13 @@ void __init sh_mv_setup(void)
129137

130138
mv_set(ioport_map);
131139
mv_set(ioport_unmap);
140+
141+
#endif
142+
132143
mv_set(irq_demux);
133144
mv_set(mode_pins);
134145
mv_set(mem_init);
135146

136147
if (!sh_mv.mv_nr_irqs)
137148
sh_mv.mv_nr_irqs = NR_IRQS;
138-
139-
#ifdef P2SEG
140-
__set_io_port_base(P2SEG);
141-
#else
142-
__set_io_port_base(0);
143-
#endif
144149
}

0 commit comments

Comments
 (0)