powerpc: Better split CONFIG_PPC_INDIRECT_PIO and CONFIG_PPC_INDIRECT_MMIO
PATCH 1/8 powerpc: Better split CONFIG_PPC_INDIRECT_PIO and CONFIG_PPC_INDIRECT_MMIO
Remove the generic PPC_INDIRECT_IO and ensure we only add overhead to the right accessors. IE. If only CONFIG_PPC_INDIRECT_PIO is set, we don't add overhead to all MMIO accessors.
--- arch/powerpc/include/asm/io.h | 25 +++++++++++++++---------- arch/powerpc/kernel/Makefile | 2 +- arch/powerpc/kernel/io-workarounds.c | 19 ++++++++++++++++++- arch/powerpc/kernel/setup_64.c | 5 ++--- arch/powerpc/platforms/Kconfig | 7 +------ 5 files changed, 37 insertions(+), 21 deletions(-)
arch/powerpc/include/asm/io.h +15 -10
@@ -69,8 +69,10 @@ extern unsigned long pci_dram_offset;extern resource_size_t isa_mem_base; -#if defined(CONFIG_PPC32 ) && defined(CONFIG_PPC_INDIRECT_IO ) -#error CONFIG_PPC_INDIRECT_IO is not yet supported on 32 bits +#ifdef CONFIG_PPC32 +#if defined(CONFIG_PPC_INDIRECT_PIO ) || defined(CONFIG_PPC_INDIRECT_MMIO ) +#error CONFIG_PPC_INDIRECT_{PIO,MMIO} are not yet supported on 32 bits +#endif #endif /*
@@ -222,9 +224,9 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,* for PowerPC is as close as possible to the x86 version of these, and thus * provides fairly heavy weight barriers for the non-raw versions * -* In addition, they support a hook mechanism when CONFIG_PPC_INDIRECT_IO -* allowing the platform to provide its own implementation of some or all -* of the accessors. +* In addition, they support a hook mechanism when CONFIG_PPC_INDIRECT_MMIO +* or CONFIG_PPC_INDIRECT_PIO are set allowing the platform to provide its +* own implementation of some or all of the accessors. */ /*
@@ -240,8 +242,8 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,/* Indirect IO address tokens: * -* When CONFIG_PPC_INDIRECT_IO is set, the platform can provide hooks -* on all IOs. (Note that this is all 64 bits only for now) +* When CONFIG_PPC_INDIRECT_MMIO is set, the platform can provide hooks +* on all MMIOs. (Note that this is all 64 bits only for now) * * To help platforms who may need to differenciate MMIO addresses in * their hooks, a bitfield is reserved for use by the platform near the
@@ -263,11 +265,14 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,* * The direct IO mapping operations will then mask off those bits * before doing the actual access, though that only happen when -* CONFIG_PPC_INDIRECT_IO is set, thus be careful when you use that +* CONFIG_PPC_INDIRECT_MMIO is set, thus be careful when you use that * mechanism +* +* For PIO, there is a separate CONFIG_PPC_INDIRECT_PIO which makes +* all PIO functions call through a hook. */ -#ifdef CONFIG_PPC_INDIRECT_IO +#ifdef CONFIG_PPC_INDIRECT_MMIO #define PCI_IO_IND_TOKEN_MASK 0x0fff000000000000ul#define PCI_IO_IND_TOKEN_SHIFT 48#define PCI_FIX_ADDR (addr) \
@@ -672,7 +677,7 @@ extern void __iomem * __ioremap_at(phys_addr_t pa, void *ea,extern void __iounmap_at (void *ea,unsigned long size);/* -* When CONFIG_PPC_INDIRECT_IO is set, we use the generic iomap implementation +* When CONFIG_PPC_INDIRECT_PIO is set, we use the generic iomap implementation * which needs some additional definitions here. They basically allow PIO * space overall to be 1GB. This will work as long as we never try to use * iomap to map MMIO below 1GB which should be fine on ppc64
arch/powerpc/kernel/Makefile +1 -1
@@ -119,7 +119,7 @@ obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o obj-$(CONFIG_8XX_MINIMAL_FPEMU) += softemu8xx.o -ifneq ($(CONFIG_PPC_INDIRECT_IO),y) +ifneq ($(CONFIG_PPC_INDIRECT_PIO),y) obj-y += iomap.o endif
arch/powerpc/kernel/io-workarounds.c +18 -1
@@ -53,6 +53,7 @@ static struct iowa_bus *iowa_pci_find(unsigned long vaddr, unsigned long paddr)return NULL ; } +#ifdef CONFIG_PPC_INDIRECT_MMIO struct iowa_bus *iowa_mem_find_bus (const PCI_IO_ADDR addr) {unsigned hugepage_shift;
@@ -90,13 +91,25 @@ struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr) return bus; } +#else /* CONFIG_PPC_INDIRECT_MMIO */ +struct iowa_bus *iowa_mem_find_bus (const PCI_IO_ADDR addr) +{ +return NULL ; +} +#endif /* !CONFIG_PPC_INDIRECT_MMIO */ +#ifdef CONFIG_PPC_INDIRECT_PIO struct iowa_bus *iowa_pio_find_bus (unsigned long port) {unsigned long vaddr = (unsigned long )pci_io_base + port;return iowa_pci_find (vaddr,0 ); } - +#else +struct iowa_bus *iowa_pio_find_bus (unsigned long port) +{ +return NULL ; +} +#endif #define DEF_PCI_AC_RET (name, ret, at, al, space, aa) \ static ret iowa_##name at \
@@ -137,6 +150,7 @@ static const struct ppc_pci_io iowa_pci_io = { }; +#ifdef CONFIG_PPC_INDIRECT_MMIO static void __iomem *iowa_ioremap (phys_addr_t addr,unsigned long size,unsigned long flags,void *caller) {
@@ -151,6 +165,9 @@ static void __iomem *iowa_ioremap(phys_addr_t addr, unsigned long size, }return res; } +#else /* CONFIG_PPC_INDIRECT_MMIO */ +#define iowa_ioremap NULL +#endif /* !CONFIG_PPC_INDIRECT_MMIO */ /* Enable IO workaround */ static void io_workaround_init (void )
arch/powerpc/kernel/setup_64.c +2 -3
@@ -701,8 +701,7 @@ void __init setup_per_cpu_areas(void)#endif -#ifdef CONFIG_PPC_INDIRECT_IO +#if defined(CONFIG_PPC_INDIRECT_PIO ) || defined(CONFIG_PPC_INDIRECT_MMIO )struct ppc_pci_io ppc_pci_io;EXPORT_SYMBOL (ppc_pci_io); -#endif /* CONFIG_PPC_INDIRECT_IO */ - +#endif
arch/powerpc/platforms/Kconfig +1 -6
@@ -202,17 +202,12 @@ config PPC_P7_NAP bool default n -config PPC_INDIRECT_IO - bool - select GENERIC_IOMAP - config PPC_INDIRECT_PIO bool - select PPC_INDIRECT_IO + select GENERIC_IOMAP config PPC_INDIRECT_MMIO bool - select PPC_INDIRECT_IO config PPC_IO_WORKAROUNDS bool
Signature · 1 line
1.8.1.2
PATCH 2/8 powerpc/powernv: Update opal.h to add new LPC and XSCOM functions
--- arch/powerpc/include/asm/opal.h | 23 +++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal-wrappers.S | 4 ++++ 2 files changed, 27 insertions(+)
arch/powerpc/include/asm/opal.h +23 -0
@@ -124,6 +124,10 @@ extern int opal_enter_rtas(struct rtas_args *args,#define OPAL_PCI_POLL 62#define OPAL_PCI_MSI_EOI 63#define OPAL_PCI_GET_PHB_DIAG_DATA2 64 +#define OPAL_XSCOM_READ 65 +#define OPAL_XSCOM_WRITE 66 +#define OPAL_LPC_READ 67 +#define OPAL_LPC_WRITE 68#ifndef __ASSEMBLY__
@@ -337,6 +341,17 @@ enum OpalEpowStatus {OPAL_EPOW_OVER_INTERNAL_TEMP =3 }; +/* +* Address cycle types for LPC accesses. These also correspond +* to the content of the first cell of the "reg" property for +* device nodes on the LPC bus +*/ +enum OpalLPCAddressType { +OPAL_LPC_MEM =0 , +OPAL_LPC_IO =1 , +OPAL_LPC_FW =2 , +}; +struct opal_machine_check_event {enum OpalMCE_Version version:8 ;/* 0x00 */ uint8_t in_use;/* 0x01 */
@@ -632,6 +647,14 @@ int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe, uint16_t *pci_error_type, uint16_t *severity);int64_t opal_pci_poll (uint64_t phb_id); +int64_t opal_xscom_read (uint32_t gcid,uint32_t pcb_addr,uint64_t *val); +int64_t opal_xscom_write (uint32_t gcid,uint32_t pcb_addr,uint64_t val); + +int64_t opal_lpc_write (uint32_t chip_id,enum OpalLPCAddressType addr_type, +uint32_t addr,uint32_t data,uint32_t sz); +int64_t opal_lpc_read (uint32_t chip_id,enum OpalLPCAddressType addr_type, +uint32_t addr,uint32_t *data,uint32_t sz); +/* Internal functions */ extern int early_init_dt_scan_opal (unsigned long node,const char *uname,int depth,void *data);
arch/powerpc/platforms/powernv/opal-wrappers.S +4 -0
@@ -111,3 +111,7 @@ OPAL_CALL(opal_pci_next_error, OPAL_PCI_NEXT_ERROR); OPAL_CALL(opal_pci_poll, OPAL_PCI_POLL); OPAL_CALL(opal_pci_msi_eoi, OPAL_PCI_MSI_EOI); OPAL_CALL(opal_pci_get_phb_diag_data2, OPAL_PCI_GET_PHB_DIAG_DATA2); +OPAL_CALL(opal_xscom_read, OPAL_XSCOM_READ); +OPAL_CALL(opal_xscom_write, OPAL_XSCOM_WRITE); +OPAL_CALL(opal_lpc_read, OPAL_LPC_READ); +OPAL_CALL(opal_lpc_write, OPAL_LPC_WRITE);
Signature · 1 line
1.8.1.2
PATCH 3/8 powerpc/powernv: Add helper to get ibm,chip-id of a node
In reply to Benjamin HerrenschmidtThis includes walking the parent nodes if necessary.
--- arch/powerpc/include/asm/prom.h | 2 ++ arch/powerpc/kernel/prom.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+)
arch/powerpc/include/asm/prom.h +2 -0
@@ -58,6 +58,8 @@ static inline int of_node_to_nid(struct device_node *device) { return 0; }extern void of_instantiate_rtc (void ); +extern int of_get_ibm_chip_id (struct device_node *np); +/* The of_drconf_cell struct defines the layout of the LMB array * specified in the device tree property * ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory
arch/powerpc/kernel/prom.c +26 -0
@@ -795,6 +795,32 @@ struct device_node *of_find_next_cache_node(struct device_node *np)return NULL ; } +/** +* of_get_ibm_chip_id - Returns the IBM "chip-id" of a device +* @np: device node of the device +* +* This looks for a property "ibm,chip-id" in the node or any +* of its parents and returns its content, or -1 if it cannot +* be found. +*/ +int of_get_ibm_chip_id (struct device_node *np) +{ +of_node_get (np); +while (np) { +struct device_node *old = np; +const __be32 *prop; + + prop =of_get_property (np,"ibm,chip-id" ,NULL ); +if (prop) { +of_node_put (np); +return be32_to_cpup (prop); + } + np =of_get_parent (np); +of_node_put (old); + } +return -1 ; +} +#ifdef CONFIG_PPC_PSERIES /* * Fix up the uninitialized fields in a new device node:
Signature · 1 line
1.8.1.2
PATCH 4/8 powerpc/powernv: Add PIO accessors for Power8 LPC bus
In reply to Benjamin HerrenschmidtThis uses the hooks provided by CONFIG_PPC_INDIRECT_PIO to implement a set of hooks for IO port access to use the LPC bus via OPAL calls for the first 64K of IO space
--- arch/powerpc/include/asm/io.h | 8 ++ arch/powerpc/include/asm/opal.h | 2 + arch/powerpc/kernel/io.c | 3 + arch/powerpc/platforms/powernv/Kconfig | 1 + arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/opal-lpc.c | 203 ++++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/powernv.h | 2 + arch/powerpc/platforms/powernv/setup.c | 6 + 8 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/platforms/powernv/opal-lpc.c
arch/powerpc/include/asm/io.h +8 -0
@@ -69,6 +69,14 @@ extern unsigned long pci_dram_offset;extern resource_size_t isa_mem_base; +/* Boolean set by platform if PIO accesses are suppored while _IO_BASE +* is not set or addresses cannot be translated to MMIO. This is typically +* set when the platform supports "special" PIO accesses via a non memory +* mapped mechanism, and allows things like the early udbg UART code to +* function. +*/ +extern bool isa_io_special; +#ifdef CONFIG_PPC32 #if defined(CONFIG_PPC_INDIRECT_PIO ) || defined(CONFIG_PPC_INDIRECT_MMIO )#error CONFIG_PPC_INDIRECT_{PIO,MMIO} are not yet supported on 32 bits
arch/powerpc/include/asm/opal.h +2 -0
@@ -687,6 +687,8 @@ extern int opal_machine_check(struct pt_regs *regs);extern void opal_shutdown (void ); +extern void opal_lpc_init (void ); +#endif /* __ASSEMBLY__ */ #endif /* __OPAL_H */
arch/powerpc/kernel/io.c +3 -0
@@ -25,6 +25,9 @@#include <asm/firmware.h> #include <asm/bug.h> +/* See definition in io.h */ +bool isa_io_special; +void _insb (const volatile u8 __iomem *port,void *buf,long count) {u8 *tbuf = buf;
arch/powerpc/platforms/powernv/Kconfig +1 -0
@@ -7,6 +7,7 @@ config PPC_POWERNV select PPC_P7_NAP select PPC_PCI_CHOICE if EMBEDDED select EPAPR_BOOT + select PPC_INDIRECT_PIO default y config POWERNV_MSI
arch/powerpc/platforms/powernv/Makefile +1 -1
@@ -1,5 +1,5 @@ obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o -obj-y += opal-rtc.o opal-nvram.o +obj-y += opal-rtc.o opal-nvram.o opal-lpc.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o
arch/powerpc/platforms/powernv/opal-lpc.c new file +203 -0
203 lines not on this page · raw message
arch/powerpc/platforms/powernv/powernv.h +2 -0
@@ -15,4 +15,6 @@ static inline void pnv_pci_init(void) { }static inline void pnv_pci_shutdown (void ) { }#endif +extern void pnv_lpc_init (void ); +#endif /* _POWERNV_H */
arch/powerpc/platforms/powernv/setup.c +6 -0
@@ -54,6 +54,12 @@ static void __init pnv_setup_arch(void)static void __init pnv_init_early (void ) { +/* +* Initialize the LPC bus now so that legacy serial +* ports can be found on it +*/ +opal_lpc_init (); +#ifdef CONFIG_HVC_OPAL if (firmware_has_feature (FW_FEATURE_OPAL ))hvc_opal_init_early ();
Signature · 1 line
1.8.1.2
PATCH 5/8 powerpc: Cleanup udbg_16550 and add support for LPC PIO-only UARTs
In reply to Benjamin HerrenschmidtThe udbg_16550 code, which we use for our early consoles and debug backends was fairly messy. Especially for the debug consoles, it would re-implement the "high level" getc/putc/poll functions for each access method. It also had code to configure the UART but only for the straight MMIO method.
This changes it to instead abstract at the register accessor level, and have the various functions and configuration routines use these.
The result is simpler and slightly smaller code, and free support for non-MMIO mapped PIO UARTs, which such as the ones that can be present on a POWER 8 LPC bus.
--- arch/powerpc/include/asm/udbg.h | 9 +- arch/powerpc/kernel/legacy_serial.c | 46 +++-- arch/powerpc/kernel/udbg_16550.c | 344 ++++++++++++++++++------------------ 3 files changed, 206 insertions(+), 193 deletions(-)
arch/powerpc/include/asm/udbg.h +5 -4
@@ -27,10 +27,11 @@ extern void udbg_printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));extern void udbg_progress (char *s,unsigned short hex); -extern void udbg_init_uart (void __iomem *comport,unsigned int speed, -unsigned int clock); -extern unsigned int udbg_probe_uart_speed (void __iomem *comport, -unsigned int clock); +extern void udbg_uart_init_mmio (void __iomem *addr,unsigned int stride); +extern void udbg_uart_init_pio (unsigned long port,unsigned int stride); + +extern void udbg_uart_setup (unsigned int speed,unsigned int clock); +extern unsigned int udbg_probe_uart_speed (unsigned int clock);struct device_node ;extern void udbg_scc_init (int force_scc);
arch/powerpc/kernel/legacy_serial.c +32 -14
72 lines not on this page · raw message
arch/powerpc/kernel/udbg_16550.c +169 -175
458 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH 6/8 powerpc: Check "status" property before adding legacy ISA serial ports
In reply to Benjamin Herrenschmidt--- arch/powerpc/kernel/legacy_serial.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/powerpc/kernel/legacy_serial.c +5 -3
@@ -386,9 +386,11 @@ void __init find_legacy_serial_ports(void)struct device_node *isa =of_get_parent (np);if (isa && (!strcmp (isa->name,"isa" ) || !strcmp (isa->name,"lpc" ))) { - index =add_legacy_isa_port (np, isa); -if (index >=0 && np == stdout) - legacy_serial_console = index; +if (of_device_is_available (np)) { + index =add_legacy_isa_port (np, isa); +if (index >=0 && np == stdout) + legacy_serial_console = index; + } }of_node_put (isa); }
Signature · 1 line
1.8.1.2
PATCH 7/8 powerpc/powernv: Don't crash if there are no OPAL consoles
In reply to Benjamin HerrenschmidtSome machines might provide the console via a different mechanism such as direct access to a UART from Linux, in which case OPAL might not expose any console. In that case, the code would cause a NULL dereference.
--- arch/powerpc/platforms/powernv/opal.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
arch/powerpc/platforms/powernv/opal.c +9 -7
@@ -380,18 +380,20 @@ static int __init opal_init(void)pr_warn ("opal: Node not found\n" );return -ENODEV ; } + +/* Register OPAL consoles if any ports */ if (firmware_has_feature (FW_FEATURE_OPALv2)) consoles =of_find_node_by_path ("/ibm,opal/consoles" );else consoles =of_node_get (opal_node); - -/* Register serial ports */ -for_each_child_of_node (consoles, np) { -if (strcmp (np->name,"serial" )) -continue ; -of_platform_device_create (np,NULL ,NULL ); +if (consoles) { +for_each_child_of_node (consoles, np) { +if (strcmp (np->name,"serial" )) +continue ; +of_platform_device_create (np,NULL ,NULL ); + } +of_node_put (consoles); } -of_node_put (consoles);/* Find all OPAL interrupts and request them */ irqs =of_get_property (opal_node,"opal-interrupts" , &irqlen);
Signature · 1 line
1.8.1.2
PATCH 8/8 powerpc/powernv: Enable detection of legacy UARTs
In reply to Benjamin HerrenschmidtLegacy UARTs can exist on PowerNV, memory-mapped ones on PCI or IO based ones on the LPC bus.
--- arch/powerpc/platforms/powernv/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/powernv/Kconfig +1 -0
@@ -8,6 +8,7 @@ config PPC_POWERNV select PPC_PCI_CHOICE if EMBEDDED select EPAPR_BOOT select PPC_INDIRECT_PIO + select PPC_UDBG_16550 default y config POWERNV_MSI
Signature · 1 line
1.8.1.2