ux500: Export SoC information and some platform clean-up
cover ux500: Export SoC information and some platform clean-up
This patch-set satisfies 4 objectives:
1. Ensures each platform device can specify a suitable parent
2. Provides a bus for SoC devices as a means to export information
3. Allows ux500 to make use of the new SoC bus
4. Cleans up unnecessary complexity from ux500 code
Documentation/ABI/testing/sysfs-devices-soc | 58 ++++++++ arch/arm/mach-ux500/Kconfig | 1 + arch/arm/mach-ux500/board-mop500-sdi.c | 31 ++-- arch/arm/mach-ux500/board-mop500.c | 74 ++++++---- arch/arm/mach-ux500/board-mop500.h | 8 +- arch/arm/mach-ux500/board-u5500-sdi.c | 4 +- arch/arm/mach-ux500/board-u5500.c | 27 +++-- arch/arm/mach-ux500/cpu-db5500.c | 36 ++++- arch/arm/mach-ux500/cpu-db8500.c | 44 +++++- arch/arm/mach-ux500/cpu.c | 75 ++++++++++ arch/arm/mach-ux500/devices-common.c | 79 +++-------- arch/arm/mach-ux500/devices-common.h | 83 ++++++----- arch/arm/mach-ux500/devices-db5500.h | 116 +++++++++------ arch/arm/mach-ux500/devices-db8500.h | 176 +++++++++++++---------- arch/arm/mach-ux500/dma-db5500.c | 3 +- arch/arm/mach-ux500/include/mach/db8500-regs.h | 3 + arch/arm/mach-ux500/include/mach/setup.h | 10 +- arch/arm/mach-ux500/include/mach/usb.h | 4 +- arch/arm/mach-ux500/usb.c | 7 +- drivers/base/Kconfig | 3 + drivers/base/Makefile | 1 + drivers/base/soc.c | 185 ++++++++++++++++++++++++ include/linux/sys_soc.h | 37 +++++ 23 files changed, 761 insertions(+), 304 deletions(-)
PATCH 1/6 mach-ux500: pass parent pointer to each platform device
This patch provides a means for any device within ux500 platform code to allocate its own parent. This is particularly prudent with the introduction of /sys/devices/socX, as a device can now proclaim to be integral part of an SoC, rather than a more generic platform device. Latter patches make good use of this functionality.
--- arch/arm/mach-ux500/board-mop500-sdi.c | 31 +++--- arch/arm/mach-ux500/board-mop500.c | 62 ++++++----- arch/arm/mach-ux500/board-mop500.h | 8 +- arch/arm/mach-ux500/board-u5500-sdi.c | 4 +- arch/arm/mach-ux500/board-u5500.c | 23 +++-- arch/arm/mach-ux500/cpu-db5500.c | 18 ++-- arch/arm/mach-ux500/cpu-db8500.c | 15 ++-- arch/arm/mach-ux500/devices-common.c | 13 ++- arch/arm/mach-ux500/devices-common.h | 39 ++++--- arch/arm/mach-ux500/devices-db5500.h | 116 ++++++++++++--------- arch/arm/mach-ux500/devices-db8500.h | 166 +++++++++++++++++------------- arch/arm/mach-ux500/dma-db5500.c | 3 +- arch/arm/mach-ux500/include/mach/setup.h | 8 +- arch/arm/mach-ux500/include/mach/usb.h | 4 +- arch/arm/mach-ux500/usb.c | 4 +- 15 files changed, 289 insertions(+), 225 deletions(-)
arch/arm/mach-ux500/board-mop500-sdi.c +16 -15
@@ -104,7 +104,7 @@ static struct mmci_platform_data mop500_sdi0_data = {#endif }; -static void sdi0_configure (void ) +static void sdi0_configure (struct device *parent) {int ret;
@@ -123,15 +123,15 @@ static void sdi0_configure(void)gpio_direction_output (sdi0_en,1 );/* Add the device, force v2 to subrevision 1 */ -db8500_add_sdi0 (&mop500_sdi0_data,U8500_SDI_V2_PERIPHID ); +db8500_add_sdi0 (parent, &mop500_sdi0_data,U8500_SDI_V2_PERIPHID ); } -void mop500_sdi_tc35892_init (void ) +void mop500_sdi_tc35892_init (struct device *parent) { mop500_sdi0_data.gpio_cd =GPIO_SDMMC_CD ; sdi0_en =GPIO_SDMMC_EN ; sdi0_vsel =GPIO_SDMMC_1V8_3V_SEL ; -sdi0_configure (); +sdi0_configure (parent); }/*
@@ -246,12 +246,13 @@ static struct mmci_platform_data mop500_sdi4_data = {#endif }; -void __init mop500_sdi_init (void ) +void __init mop500_sdi_init (struct device *parent) {/* PoP:ed eMMC */ -db8500_add_sdi2 (&mop500_sdi2_data,U8500_SDI_V2_PERIPHID ); +db8500_add_sdi2 (parent, &mop500_sdi2_data,U8500_SDI_V2_PERIPHID );/* On-board eMMC */ -db8500_add_sdi4 (&mop500_sdi4_data,U8500_SDI_V2_PERIPHID ); +db8500_add_sdi4 (parent, &mop500_sdi4_data,U8500_SDI_V2_PERIPHID ); +/* * On boards with the TC35892 GPIO expander, sdi0 will finally * be added when the TC35892 initializes and calls
@@ -259,29 +260,29 @@ void __init mop500_sdi_init(void)*/ } -void __init snowball_sdi_init (void ) +void __init snowball_sdi_init (struct device *parent) {/* On-board eMMC */ -db8500_add_sdi4 (&mop500_sdi4_data,U8500_SDI_V2_PERIPHID ); +db8500_add_sdi4 (parent, &mop500_sdi4_data,U8500_SDI_V2_PERIPHID );/* External Micro SD slot */ mop500_sdi0_data.gpio_cd =SNOWBALL_SDMMC_CD_GPIO ; mop500_sdi0_data.cd_invert = true; sdi0_en =SNOWBALL_SDMMC_EN_GPIO ; sdi0_vsel =SNOWBALL_SDMMC_1V8_3V_GPIO ; -sdi0_configure (); +sdi0_configure (parent); } -void __init hrefv60_sdi_init (void ) +void __init hrefv60_sdi_init (struct device *parent) {/* PoP:ed eMMC */ -db8500_add_sdi2 (&mop500_sdi2_data,U8500_SDI_V2_PERIPHID ); +db8500_add_sdi2 (parent, &mop500_sdi2_data,U8500_SDI_V2_PERIPHID );/* On-board eMMC */ -db8500_add_sdi4 (&mop500_sdi4_data,U8500_SDI_V2_PERIPHID ); +db8500_add_sdi4 (parent, &mop500_sdi4_data,U8500_SDI_V2_PERIPHID );/* External Micro SD slot */ mop500_sdi0_data.gpio_cd =HREFV60_SDMMC_CD_GPIO ; sdi0_en =HREFV60_SDMMC_EN_GPIO ; sdi0_vsel =HREFV60_SDMMC_1V8_3V_GPIO ; -sdi0_configure (); +sdi0_configure (parent);/* WLAN SDIO channel */ -db8500_add_sdi1 (&mop500_sdi1_data,U8500_SDI_V2_PERIPHID ); +db8500_add_sdi1 (parent, &mop500_sdi1_data,U8500_SDI_V2_PERIPHID ); }
arch/arm/mach-ux500/board-mop500.c +35 -27
137 lines not on this page · raw message
arch/arm/mach-ux500/board-mop500.h +4 -4
@@ -75,10 +75,10 @@struct i2c_board_info ; -extern void mop500_sdi_init (void ); -extern void snowball_sdi_init (void ); -extern void hrefv60_sdi_init (void ); -extern void mop500_sdi_tc35892_init (void ); +extern void mop500_sdi_init (struct device *parent); +extern void snowball_sdi_init (struct device *parent); +extern void hrefv60_sdi_init (struct device *parent); +extern void mop500_sdi_tc35892_init (struct device *parent);void __init mop500_u8500uib_init (void );void __init mop500_stuib_init (void );void __init mop500_pins_init (void );
arch/arm/mach-ux500/board-u5500-sdi.c +2 -2
@@ -66,9 +66,9 @@ static struct mmci_platform_data u5500_sdi0_data = {#endif }; -void __init u5500_sdi_init (void ) +void __init u5500_sdi_init (struct device *parent) {nmk_config_pins (u5500_sdi_pins,ARRAY_SIZE (u5500_sdi_pins)); -db5500_add_sdi0 (&u5500_sdi0_data); +db5500_add_sdi0 (parent, &u5500_sdi0_data); }
arch/arm/mach-ux500/board-u5500.c +13 -10
@@ -97,9 +97,9 @@ static struct i2c_board_info __initdata u5500_i2c2_devices[] = { }, }; -static void __init u5500_i2c_init (void ) +static void __init u5500_i2c_init (struct device *parent) { -db5500_add_i2c2 (&u5500_i2c2_data); +db5500_add_i2c2 (parent, &u5500_i2c2_data);i2c_register_board_info (2 ,ARRAY_AND_SIZE (u5500_i2c2_devices)); }
@@ -126,20 +126,23 @@ static struct platform_device *u5500_platform_devices[] __initdata = { &ab5500_device, }; -static void __init u5500_uart_init (void ) +static void __init u5500_uart_init (struct device *parent) { -db5500_add_uart0 (NULL ); -db5500_add_uart1 (NULL ); -db5500_add_uart2 (NULL ); +db5500_add_uart0 (parent,NULL ); +db5500_add_uart1 (parent,NULL ); +db5500_add_uart2 (parent,NULL ); }static void __init u5500_init_machine (void ) { -u5500_init_devices (); +struct device *parent =NULL ; + + parent =u5500_init_devices ();nmk_config_pins (u5500_pins,ARRAY_SIZE (u5500_pins)); -u5500_i2c_init (); -u5500_sdi_init (); -u5500_uart_init (); + +u5500_i2c_init (parent); +u5500_sdi_init (parent); +u5500_uart_init (parent);platform_add_devices (u5500_platform_devices,ARRAY_SIZE (u5500_platform_devices));
arch/arm/mach-ux500/cpu-db5500.c +11 -7
@@ -147,13 +147,13 @@ static resource_size_t __initdata db5500_gpio_base[] = { U5500_GPIOBANK7_BASE, }; -static void __init db5500_add_gpios (void ) +static void __init db5500_add_gpios (struct device *parent) {struct nmk_gpio_platform_data pdata = {/* No custom data yet */ }; -dbx500_add_gpios (ARRAY_AND_SIZE (db5500_gpio_base), +dbx500_add_gpios (parent,ARRAY_AND_SIZE (db5500_gpio_base),IRQ_DB5500_GPIO0 , &pdata); }
@@ -212,14 +212,18 @@ static int usb_db5500_tx_dma_cfg[] = { DB5500_DMA_DEV38_USB_OTG_OEP_8 }; -void __init u5500_init_devices (void ) +struct device *__init u5500_init_devices (void ) { -db5500_add_gpios (); +/* FIXME: First parameter to be a real parent. */ +db5500_add_gpios (NULL );db5500_pmu_init (); -db5500_dma_init (); -db5500_add_rtc (); -db5500_add_usb (usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg); +db5500_dma_init (NULL ); +db5500_add_rtc (NULL ); +db5500_add_usb (NULL , usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);platform_add_devices (db5500_platform_devs,ARRAY_SIZE (db5500_platform_devs)); + +/* FIXME: Return value to be a real parent. */ +return NULL ; }
arch/arm/mach-ux500/cpu-db8500.c +8 -7
@@ -132,13 +132,13 @@ static resource_size_t __initdata db8500_gpio_base[] = { U8500_GPIOBANK8_BASE, }; -static void __init db8500_add_gpios (void ) +static void __init db8500_add_gpios (struct device *parent) {struct nmk_gpio_platform_data pdata = { .supports_sleepmode = true, }; -dbx500_add_gpios (ARRAY_AND_SIZE (db8500_gpio_base), +dbx500_add_gpios (parent,ARRAY_AND_SIZE (db8500_gpio_base),IRQ_DB8500_GPIO0 , &pdata); }
@@ -167,14 +167,15 @@ static int usb_db8500_tx_dma_cfg[] = {/* * This function is called from the board init */ -void __init u8500_init_devices (void ) +struct device *__init u8500_init_devices (void ) { -db8500_add_rtc (); -db8500_add_gpios (); -db8500_add_usb (usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg); +db8500_add_rtc (NULL ); +db8500_add_gpios (NULL ); +db8500_add_usb (NULL , usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg);platform_device_register_simple ("cpufreq-u8500" ,-1 ,NULL ,0 );platform_add_devices (platform_devs,ARRAY_SIZE (platform_devs)); -return ; +/* FIXME: Return value to be a real parent. */ +return NULL ; }
arch/arm/mach-ux500/devices-common.c +7 -6
@@ -20,8 +20,9 @@#include "devices-common.h" struct amba_device * -dbx500_add_amba_device (const char *name,resource_size_t base, -int irq,void *pdata,unsigned int periphid) +dbx500_add_amba_device (struct device *parent,const char *name, +resource_size_t base,int irq,void *pdata, +unsigned int periphid) {struct amba_device *dev;int ret;
@@ -109,7 +110,7 @@ dbx500_add_platform_device_4k1irq(const char *name, int id, }static struct platform_device * -dbx500_add_gpio (int id,resource_size_t addr,int irq, +dbx500_add_gpio (struct device *parent,int id,resource_size_t addr,int irq,struct nmk_gpio_platform_data *pdata) {struct resource resources[] = {
@@ -130,8 +131,8 @@ dbx500_add_gpio(int id, resource_size_t addr, int irq, pdata, sizeof(*pdata)); } -void dbx500_add_gpios (resource_size_t *base,int num,int irq, -struct nmk_gpio_platform_data *pdata) +void dbx500_add_gpios (struct device *parent,resource_size_t *base,int num, +int irq,struct nmk_gpio_platform_data *pdata) {int first =0 ;int i;
@@ -141,6 +142,6 @@ void dbx500_add_gpios(resource_size_t *base, int num, int irq, pdata->first_irq =NOMADIK_GPIO_TO_IRQ (first); pdata->num_gpio =32 ; -dbx500_add_gpio (i, base[i], irq, pdata); +dbx500_add_gpio (parent, i, base[i], irq, pdata); } }
arch/arm/mach-ux500/devices-common.h +21 -18
@@ -9,7 +9,7 @@#define __DEVICES_COMMON_Hextern struct amba_device * -dbx500_add_amba_device (const char *name,resource_size_t base, +dbx500_add_amba_device (struct device *parent,const char *name,resource_size_t base,int irq,void *pdata,unsigned int periphid); extern struct platform_device *
@@ -20,43 +20,46 @@ dbx500_add_platform_device_4k1irq(const char *name, int id,struct spi_master_cntlr ;static inline struct amba_device * -dbx500_add_msp_spi (const char *name,resource_size_t base,int irq, +dbx500_add_msp_spi (struct device *parent,const char *name, +resource_size_t base,int irq,struct spi_master_cntlr *pdata) { -return dbx500_add_amba_device (name, base, irq, pdata,0 ); +return dbx500_add_amba_device (parent, name, base, irq, + pdata,0 ); }static inline struct amba_device * -dbx500_add_spi (const char *name,resource_size_t base,int irq, -struct spi_master_cntlr *pdata, +dbx500_add_spi (struct device *parent,const char *name,resource_size_t base, +int irq,struct spi_master_cntlr *pdata,u32 periphid) { -return dbx500_add_amba_device (name, base, irq, pdata, periphid); +return dbx500_add_amba_device (parent, name, base, irq, + pdata, periphid); }struct mmci_platform_data ;static inline struct amba_device * -dbx500_add_sdi (const char *name,resource_size_t base,int irq, -struct mmci_platform_data *pdata, -u32 periphid) +dbx500_add_sdi (struct device *parent,const char *name,resource_size_t base, +int irq,struct mmci_platform_data *pdata,u32 periphid) { -return dbx500_add_amba_device (name, base, irq, pdata, periphid); +return dbx500_add_amba_device (parent, name, base, irq, + pdata, periphid); }struct amba_pl011_data ;static inline struct amba_device * -dbx500_add_uart (const char *name,resource_size_t base,int irq, -struct amba_pl011_data *pdata) +dbx500_add_uart (struct device *parent,const char *name,resource_size_t base, +int irq,struct amba_pl011_data *pdata) { -return dbx500_add_amba_device (name, base, irq, pdata,0 ); +return dbx500_add_amba_device (parent, name, base, irq, pdata,0 ); }struct nmk_i2c_controller ;static inline struct platform_device * -dbx500_add_i2c (int id,resource_size_t base,int irq, +dbx500_add_i2c (struct device *parent,int id,resource_size_t base,int irq,struct nmk_i2c_controller *pdata) { return dbx500_add_platform_device_4k1irq("nmk-i2c", id, base, irq,
@@ -74,14 +77,14 @@ dbx500_add_msp_i2s(int id, resource_size_t base, int irq, }static inline struct amba_device * -dbx500_add_rtc (resource_size_t base,int irq) +dbx500_add_rtc (struct device *parent,resource_size_t base,int irq) { -return dbx500_add_amba_device ("rtc-pl031" , base, irq,NULL ,0 ); +return dbx500_add_amba_device (parent,"rtc-pl031" , base, irq,NULL ,0 ); }struct nmk_gpio_platform_data ; -void dbx500_add_gpios (resource_size_t *base,int num,int irq, -struct nmk_gpio_platform_data *pdata); +void dbx500_add_gpios (struct device *parent,resource_size_t *base,int num, +int irq,struct nmk_gpio_platform_data *pdata);#endif
arch/arm/mach-ux500/devices-db5500.h +68 -48
138 lines not on this page · raw message
arch/arm/mach-ux500/devices-db8500.h +94 -72
181 lines not on this page · raw message
arch/arm/mach-ux500/dma-db5500.c +2 -1
@@ -125,10 +125,11 @@ static struct platform_device dma40_device = { .resource = dma40_resources }; -void __init db5500_dma_init (void ) +void __init db5500_dma_init (struct device *parent) {int ret; + dma40_device.dev.parent = parent; ret =platform_device_register (&dma40_device);if (ret)dev_err (&dma40_device.dev,"unable to register device: %d\n" , ret);
arch/arm/mach-ux500/include/mach/setup.h +4 -4
@@ -18,14 +18,14 @@ void __init ux500_map_io(void);extern void __init u5500_map_io (void );extern void __init u8500_map_io (void ); -extern void __init u5500_init_devices (void ); -extern void __init u8500_init_devices (void ); +extern struct device *__init u5500_init_devices (void ); +extern struct device *__init u8500_init_devices (void );extern void __init ux500_init_irq (void ); -extern void __init u5500_sdi_init (void ); +extern void __init u5500_sdi_init (struct device *parent); -extern void __init db5500_dma_init (void ); +extern void __init db5500_dma_init (struct device *parent);/* We re-use nomadik_timer for this platform */ extern void nmdk_timer_init (void );
arch/arm/mach-ux500/include/mach/usb.h +2 -2
@@ -20,6 +20,6 @@ struct ux500_musb_board_data { bool (*dma_filter)(struct dma_chan *chan, void *filter_param); }; -void ux500_add_usb (resource_size_t base,int irq,int *dma_rx_cfg, -int *dma_tx_cfg); +void ux500_add_usb (struct device *parent,resource_size_t base, +int irq,int *dma_rx_cfg,int *dma_tx_cfg);#endif
arch/arm/mach-ux500/usb.c +2 -2
@@ -146,8 +146,8 @@ static inline void ux500_usb_dma_update_tx_ch_config(int *dst_dev_type) musb_dma_tx_ch[idx].dst_dev_type = dst_dev_type[idx]; } -void ux500_add_usb (resource_size_t base,int irq,int *dma_rx_cfg, -int *dma_tx_cfg) +void ux500_add_usb (struct device *parent,resource_size_t base,int irq, +int *dma_rx_cfg,int *dma_tx_cfg) { ux500_musb_device.resource[0 ].start = base; ux500_musb_device.resource[0 ].end = base +SZ_64K -1 ;
Signature · 1 line
1.7.5.4
PATCH 2/6 drivers/base: add bus for System-on-Chip devices
In reply to Lee JonesTraditionally, any System-on-Chip based platform creates a flat list of platform_devices directly under /sys/devices/platform.
In order to give these some better structure, this introduces a new bus type for soc_devices that are registered with the new soc_device_register() function. All devices that are on the same chip should then be registered as child devices of the soc device.
The soc bus also exports a few standardised device attributes which allow user space to query the specific type of soc.
--- drivers/base/Kconfig | 3 + drivers/base/Makefile | 1 + drivers/base/soc.c | 185 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/sys_soc.h | 37 ++++++++++ 4 files changed, 226 insertions(+), 0 deletions(-) create mode 100644 drivers/base/soc.c create mode 100644 include/linux/sys_soc.h
drivers/base/Kconfig +3 -0
@@ -176,6 +176,9 @@ config GENERIC_CPU_DEVICES bool default n +config SOC_BUS + bool + source "drivers/base/regmap/Kconfig" config DMA_SHARED_BUFFER
drivers/base/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_MODULES) += module.o endif obj-$(CONFIG_SYS_HYPERVISOR) += hypervisor.o obj-$(CONFIG_REGMAP) += regmap/ +obj-$(CONFIG_SOC_BUS) += soc.o ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG
drivers/base/soc.c new file +185 -0
185 lines not on this page · raw message
include/linux/sys_soc.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (C) ST-Ericsson SA 2011 +* Author: Lee Jones <[email protected]> for ST-Ericsson. +* License terms: GNU General Public License (GPL), version 2 +*/ +#ifndef __SOC_BUS_H +#define __SOC_BUS_H + +#include <linux/device.h> + +struct soc_device_attribute { +const char *machine; +const char *family; +const char *revision; +const char *soc_id; +}; + +/** +* soc_device_register - register SoC as a device +* @soc_plat_dev_attr: Attributes passed from platform to be attributed to a SoC +*/ +struct soc_device *soc_device_register ( +struct soc_device_attribute *soc_plat_dev_attr); + +/** +* soc_device_unregister - unregister SoC device +* @dev: SoC device to be unregistered +*/ +void soc_device_unregister (struct soc_device *soc_dev); + +/** +* soc_device_to_device - helper function to fetch struct device +* @soc: Previously registered SoC device container +*/ +struct device *soc_device_to_device (struct soc_device *soc); + +#endif /* __SOC_BUS_H */
Signature · 1 line
1.7.5.4
PATCH 2/6 drivers/base: add bus for System-on-Chip devices
Quoted 26 lines · Lee Jones
Traditionally, any System-on-Chip based platform creates a flat list of
platform_devicesdirectly under/sys/devices/platform.In order to give these some better structure, this introduces a new bus type for
soc_devicesthat are registered with the newsoc_device_register()function. All devices that are on the same chip should then be registered as child devices of the soc device.The soc bus also exports a few standardised device attributes which allow user space to query the specific type of soc.
Signed-off-by Lee Jones <[email protected]>--- drivers/base/Kconfig | 3 + drivers/base/Makefile | 1 + drivers/base/soc.c | 185 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/sys_soc.h | 37 ++++++++++ 4 files changed, 226 insertions(+), 0 deletions(-) create mode 100644 drivers/base/soc.c create mode 100644 include/linux/sys_soc.hdrivers/base/Kconfig +0
-0
drivers/base/Kconfig config GENERIC_CPU_DEVICES · line 180
Quoted 5 lines
drivers/base/Kconfig +2
-0@@ -176,6 +176,9 @@ config GENERIC_CPU_DEVICES bool default n +config SOC_BUS + bool
That's nice, but you do need some kind of help text here, right?
Quoted 36 lines
drivers/base/Kconfig +1
-0+ source "drivers/base/regmap/Kconfig" config DMA_SHARED_BUFFERdrivers/base/Makefile +1
-0@@ -19,6 +19,7 @@ obj-$(CONFIG_MODULES) += module.o endif obj-$(CONFIG_SYS_HYPERVISOR) += hypervisor.o obj-$(CONFIG_REGMAP) += regmap/ +obj-$(CONFIG_SOC_BUS) += soc.o ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUGdrivers/base/soc.c new file +14
-0@@ -0,0 +1,185 @@ +/* +* Copyright (C) ST-Ericsson SA 2011 +* +* Author: Lee Jones <[email protected]> for ST-Ericsson. +* License terms: GNU General Public License (GPL), version 2 +*/ + +#include <linux/sysfs.h> +#include <linux/module.h> +#include <linux/init.h> +#include <linux/stat.h> +#include <linux/slab.h> +#include <linux/idr.h> +#include <linux/spinlock.h>
drivers/base/soc.c line 24
Quoted 10 lines
drivers/base/soc.c new file +10
-0+#include <linux/sys_soc.h> +#include <linux/err.h> + +static struct ida soc_ida; +static spinlock_t soc_lock; + +static ssize_t soc_info_get (struct device *dev, +struct device_attribute *attr, +char *buf); +
Why not put the whole function here, well a few lines lower, so no forward declaration is needed, saving a few extra lines.
drivers/base/soc.c line 27
Quoted 3 lines
drivers/base/soc.c new file +3
-0+struct soc_device { +struct device dev; +struct soc_device_attribute *attr;
const?
drivers/base/soc.c line 28
Quoted 1 line
drivers/base/soc.c new file +1
-0+int soc_dev_num;
Why is this needed? What's wrong with dev->id?
drivers/base/soc.c line 34
Quoted 6 lines
drivers/base/soc.c new file +6
-0+}; + +static struct bus_type soc_bus_type = { + .name ="soc" , +}; +
Put the function here.
drivers/base/soc.c line 43
Quoted 9 lines
drivers/base/soc.c new file +9
-0+static DEVICE_ATTR(machine, S_IRUGO, soc_info_get, NULL); +static DEVICE_ATTR(family, S_IRUGO, soc_info_get, NULL); +static DEVICE_ATTR(soc_id, S_IRUGO, soc_info_get, NULL); +static DEVICE_ATTR(revision, S_IRUGO, soc_info_get, NULL); + +struct device *soc_device_to_device (struct soc_device *soc_dev) +{ +return &soc_dev->dev; +}
Why is this even needed? Who cares about this?
Quoted 45 lines
drivers/base/soc.c new file +45
-0+ +static mode_t soc_attribute_mode (struct kobject *kobj, +struct attribute *attr, +int index) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct soc_device *soc_dev = container_of(dev, struct soc_device, dev); + +if ((attr == &dev_attr_machine.attr) + && (soc_dev->attr->machine !=NULL )) +return attr->mode; +if ((attr == &dev_attr_family.attr) + && (soc_dev->attr->family !=NULL )) +return attr->mode; +if ((attr == &dev_attr_revision.attr) + && (soc_dev->attr->revision !=NULL )) +return attr->mode; +if ((attr == &dev_attr_soc_id.attr) + && (soc_dev->attr->soc_id !=NULL )) +return attr->mode; + +/* Unknown or unfilled attribute. */ +return 0 ; +} + +static ssize_t soc_info_get (struct device *dev, +struct device_attribute *attr, +char *buf) +{ + struct soc_device *soc_dev = container_of(dev, struct soc_device, dev); + +if (attr == &dev_attr_machine) +return sprintf (buf,"%s\n" , soc_dev->attr->machine); +if (attr == &dev_attr_family) +return sprintf (buf,"%s\n" , soc_dev->attr->family); +if (attr == &dev_attr_revision) +return sprintf (buf,"%s\n" , soc_dev->attr->revision); +if (attr == &dev_attr_soc_id) +return sprintf (buf,"%s\n" , soc_dev->attr->soc_id); + +return -EINVAL ; + +} + +static struct attribute *soc_attr[] = {
drivers/base/soc.c line 98
Quoted 10 lines
drivers/base/soc.c new file +10
-0+ &dev_attr_machine.attr, + &dev_attr_family.attr, + &dev_attr_soc_id.attr, + &dev_attr_revision.attr, + NULL, +}; + +static const struct attribute_group soc_attr_group = { + .attrs = soc_attr, + .is_visible = soc_attribute_mode,
Nice, now wasn't that easier? :)
Quoted 106 lines
drivers/base/soc.c new file +87
-0+}; + +static const struct attribute_group *soc_attr_groups[] = { + &soc_attr_group, +NULL , +}; + +static void soc_release (struct device *dev) +{ + struct soc_device *soc_dev = container_of(dev, struct soc_device, dev); + +kfree (soc_dev); +} + +struct soc_device *soc_device_register (struct soc_device_attribute *soc_dev_attr) +{ +struct soc_device *soc_dev; +int ret; + + soc_dev =kzalloc (sizeof (*soc_dev),GFP_KERNEL ); +if (!soc_dev) { + ret = -ENOMEM ; + goto out1; + } + +/* Fetch a unique (reclaimable) SOC ID. */ +do { +if (!ida_pre_get (&soc_ida,GFP_KERNEL )) { + ret = -ENOMEM ; + goto out2; + } + +spin_lock (&soc_lock); + ret =ida_get_new (&soc_ida, &soc_dev->soc_dev_num); +spin_unlock (&soc_lock); + + }while (ret == -EAGAIN ); + +if (ret) + goto out2; + + soc_dev->attr = soc_dev_attr; + soc_dev->dev.bus = &soc_bus_type; + soc_dev->dev.groups = soc_attr_groups; + soc_dev->dev.release = soc_release; + +dev_set_name (&soc_dev->dev,"soc%d" , soc_dev->soc_dev_num); + + ret =device_register (&soc_dev->dev); +if (ret) + goto out3; + +return soc_dev; + +out3: +ida_remove (&soc_ida, soc_dev->soc_dev_num); +out2: +kfree (soc_dev); +out1: +return ERR_PTR (ret); +} + +/* Ensure soc_dev->attr is freed prior to calling soc_device_unregister. */ +void soc_device_unregister (struct soc_device *soc_dev) +{ +ida_remove (&soc_ida, soc_dev->soc_dev_num); + +device_unregister (&soc_dev->dev); +} + +static int __init soc_bus_register (void ) +{ +spin_lock_init (&soc_lock); + +ida_init (&soc_ida); + +return bus_register (&soc_bus_type); +} +core_initcall (soc_bus_register); + +static void __exit soc_bus_unregister(void) +{ +ida_destroy (&soc_ida); + +bus_unregister (&soc_bus_type); +} +module_exit (soc_bus_unregister);include/linux/sys_soc.h new file +13
-0@@ -0,0 +1,37 @@ +/* +* Copyright (C) ST-Ericsson SA 2011 +* Author: Lee Jones <[email protected]> for ST-Ericsson. +* License terms: GNU General Public License (GPL), version 2 +*/ +#ifndef __SOC_BUS_H +#define __SOC_BUS_H + +#include <linux/device.h> + +struct soc_device_attribute { + const char *machine; + const char *family;
include/linux/sys_soc.h line 23
Quoted 10 lines
include/linux/sys_soc.h new file +10
-0+const char *revision; +const char *soc_id; +}; + +/** +* soc_device_register - register SoC as a device +* @soc_plat_dev_attr: Attributes passed from platform to be attributed to a SoC +*/ +struct soc_device *soc_device_register ( +struct soc_device_attribute *soc_plat_dev_attr);
const?
include/linux/sys_soc.h line 29
Quoted 6 lines
include/linux/sys_soc.h new file +6
-0+ +/** +* soc_device_unregister - unregister SoC device +* @dev: SoC device to be unregistered +*/ +void soc_device_unregister (struct soc_device *soc_dev);
We need more documentation for these functions.
include/linux/sys_soc.h line 35
Quoted 6 lines
include/linux/sys_soc.h new file +6
-0+ +/** +* soc_device_to_device - helper function to fetch struct device +* @soc: Previously registered SoC device container +*/ +struct device *soc_device_to_device (struct soc_device *soc);
Is the reference count incremented when this is called? Why is this needed at all anyway?
Overall, much nicer, but we need more documentation on how to use this properly, and what exactly it does.
You are almost there :)
thanks,
greg k-h
PATCH 2/6 drivers/base: add bus for System-on-Chip devices
Quoted 9 lines · Greg KH
Quoted 8 lines · Lee Jones
drivers/base/Kconfig +0
-0@@ -176,6 +176,9 @@ config GENERIC_CPU_DEVICES bool default n
Quoted 4 lines
drivers/base/Kconfig config GENERIC_CPU_DEVICES · line 180
Quoted 2 lines
drivers/base/Kconfig +2
-0+config SOC_BUS + boolThat's nice, but you do need some kind of help text here, right?
Wouldn't hurt, but most silent options have no help text, because that would never be visible in the kconfig tools, only in the source code.
Quoted 11 lines
drivers/base/Kconfig config GENERIC_CPU_DEVICES
Quoted 8 lines
drivers/base/Kconfig +8
-0+ +static struct ida soc_ida; +static spinlock_t soc_lock; + +static ssize_t soc_info_get(struct device *dev, + struct device_attribute *attr, + char *buf); +Why not put the whole function here, well a few lines lower, so no forward declaration is needed, saving a few extra lines.
You made the same comment in a previous review round and then agreed that it's correct after all. A small comment why the forward declaration is required here would probably be appropriate here, otherwise the next person reading this would have the same thought.
Quoted 13 lines
Quoted 13 lines
drivers/base/Kconfig +13
-0+ +static mode_t soc_attribute_mode(struct kobject *kobj, + struct attribute *attr, + int index) +{ + struct device *dev = container_of(kobj, struct device, kobj); + struct soc_device *soc_dev = container_of(dev, struct soc_device, dev); + + if ((attr == &dev_attr_machine.attr) + && (soc_dev->attr->machine != NULL)) + return attr->mode; + if ((attr == &dev_attr_family.attr) + && (soc_dev->attr->family != NULL))
Quoted 8 lines
drivers/base/Kconfig
Quoted 8 lines
drivers/base/Kconfig +8
-0+ return attr->mode; + if ((attr == &dev_attr_revision.attr) + && (soc_dev->attr->revision != NULL)) + return attr->mode; + if ((attr == &dev_attr_soc_id.attr) + && (soc_dev->attr->soc_id != NULL)) + return attr->mode; +
FWIW, the function compares the attribute pointers, so it needs to see their delarations, while the attribute definition requires the declaration of the function to be visible.
Arnd
PATCH 2/6 drivers/base: add bus for System-on-Chip devices
Quoted 10 lines · Arnd Bergmann
Quoted 9 lines · Greg KH
Quoted 8 lines · Lee Jones
drivers/base/Kconfig +0
-0@@ -176,6 +176,9 @@ config GENERIC_CPU_DEVICES bool default n
Quoted 7 lines
Quoted 4 lines
drivers/base/Kconfig config GENERIC_CPU_DEVICES · line 180
Quoted 2 lines
drivers/base/Kconfig +2
-0+config SOC_BUS + boolThat's nice, but you do need some kind of help text here, right?
Wouldn't hurt, but most silent options have no help text, because that would never be visible in the kconfig tools, only in the source code.
Ah, it's being set by others, ok, that's fine.
Quoted 11 lines
Quoted 10 lines
drivers/base/Kconfig config GENERIC_CPU_DEVICES
Quoted 7 lines
drivers/base/Kconfig +7
-0+static struct ida soc_ida; +static spinlock_t soc_lock; + +static ssize_t soc_info_get(struct device *dev, + struct device_attribute *attr, + char *buf); +Why not put the whole function here, well a few lines lower, so no forward declaration is needed, saving a few extra lines.
Quoted 4 lines
You made the same comment in a previous review round and then agreed that it's correct after all. A small comment why the forward declaration is required here would probably be appropriate here, otherwise the next person reading this would have the same thought.
Heh, at least I'm consistant with my requests :)
And yes, you are right, this is fine, a small comment would be good to have so that I don't make the same review comment the next time around.
thanks,
greg k-h
PATCH 3/6 Documentation: add information for new sysfs soc bus functionality
In reply to Lee JonesThis change applies the required documentation for each new attribute recenty added by the new System-On-Chip (SoC) information export bus driver.
--- Documentation/ABI/testing/sysfs-devices-soc | 58 +++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-devices-soc
Documentation/ABI/testing/sysfs-devices-soc new file +58 -0
@@ -0,0 +1,58 @@ +What: /sys/devices/socX +Date: January 2012 +contact: Lee Jones <[email protected]> +Description: + The /sys/devices/ directory contains a sub-directory for each + System-on-Chip (SoC) device on a running platform. Information + regarding each SoC can be obtained by reading sysfs files. This + functionality is only available if implemented by the platform. + + The directory created for each SoC will also house information + about devices which are commonly contained in /sys/devices/platform. + It has been agreed that if an SoC device exists, its supported + devices would be better suited to appear as children of that SoC. + +What: /sys/devices/socX/machine +Date: January 2012 +contact: Lee Jones <[email protected]> +Description: + Read-only attribute common to all SoCs. Contains the SoC machine + name (e.g. Ux500). + +What: /sys/devices/socX/family +Date: January 2012 +contact: Lee Jones <[email protected]> +Description: + Read-only attribute common to all SoCs. Contains SoC family name + (e.g. DB8500). + +What: /sys/devices/socX/soc_id +Date: January 2012 +contact: Lee Jones <[email protected]> +Description: + Read-only attribute supported by most SoCs. In the case of + ST-Ericsson's chips this contains the SoC serial number. + +What: /sys/devices/socX/revision +Date: January 2012 +contact: Lee Jones <[email protected]> +Description: + Read-only attribute supported by most SoCs. Contains the SoC's + manufacturing revision number. + +What: /sys/devices/socX/process +Date: January 2012 +contact: Lee Jones <[email protected]> +Description: + Read-only attribute supported ST-Ericsson's silicon. Contains the + the process by which the silicon chip was manufactured. + +What: /sys/bus/soc +Date: January 2012 +contact: Lee Jones <[email protected]> +Description: + The /sys/bus/soc/ directory contains the usual sub-folders + expected under most buses. /sys/bus/soc/devices is of particular + interest, as it contains a symlink for each SoC device found on + the system. Each symlink points back into the aforementioned + /sys/devices/socX devices.
Signature · 1 line
1.7.5.4
PATCH 4/6 mach-ux500: export System-on-Chip information ux500 via sysfs
In reply to Lee JonesHere we make use of the new System-On-Chip bus driver to export vital SoC information out to userspace via sysfs. This patch provides a data structure of strings to populate the base nodes found in:
/sys/devices/soc[0|1|2|...]/[family|machine|revision|soc_id].
It also adds one more node as requested by ST-Ericsson. 'process' depicts the way in which the silicon was manufactured.
--- arch/arm/mach-ux500/Kconfig | 1 + arch/arm/mach-ux500/cpu-db5500.c | 30 +++++++--- arch/arm/mach-ux500/cpu-db8500.c | 33 +++++++++-- arch/arm/mach-ux500/cpu.c | 75 ++++++++++++++++++++++++ arch/arm/mach-ux500/include/mach/db8500-regs.h | 3 + arch/arm/mach-ux500/include/mach/setup.h | 2 + 6 files changed, 130 insertions(+), 14 deletions(-)
arch/arm/mach-ux500/Kconfig +1 -0
@@ -27,6 +27,7 @@ config MACH_U8500 bool "U8500 Development platform" depends on UX500_SOC_DB8500 select TPS6105X + select SOC_BUS help Include support for the mop500 development platform.
arch/arm/mach-ux500/cpu-db5500.c +22 -8
@@ -212,18 +212,32 @@ static int usb_db5500_tx_dma_cfg[] = { DB5500_DMA_DEV38_USB_OTG_OEP_8 }; -struct device *__init u5500_init_devices (void ) +static const char *db5500_read_soc_id (void ) { -/* FIXME: First parameter to be a real parent. */ -db5500_add_gpios (NULL ); +return kasprintf (GFP_KERNEL ,"u5500 currently unsupported\n" ); +} + +static struct device *__init db5500_soc_device_init (void ) +{ +const char *soc_id =db5500_read_soc_id (); + +return ux500_soc_device_init (soc_id); +} + +struct device *__init u5500_init_devices (void ) +{ +struct device *parent; + + parent =db5500_soc_device_init (); + +db5500_add_gpios (parent);db5500_pmu_init (); -db5500_dma_init (NULL ); -db5500_add_rtc (NULL ); -db5500_add_usb (NULL , usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg); +db5500_dma_init (parent); +db5500_add_rtc (parent); +db5500_add_usb (parent, usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);platform_add_devices (db5500_platform_devs,ARRAY_SIZE (db5500_platform_devs)); -/* FIXME: Return value to be a real parent. */ -return NULL ; +return parent; }
arch/arm/mach-ux500/cpu-db8500.c +27 -6
@@ -24,6 +24,7 @@#include <mach/setup.h> #include <mach/devices.h> #include <mach/usb.h> +#include <mach/db8500-regs.h> #include "devices-db8500.h" #include "ste-dma40-db8500.h"
@@ -164,18 +165,38 @@ static int usb_db8500_tx_dma_cfg[] = {DB8500_DMA_DEV39_USB_OTG_OEP_8 }; +static const char *db8500_read_soc_id (void ) +{ +void __iomem *uid =__io_address (U8500_BB_UID_BASE ); + +return kasprintf (GFP_KERNEL ,"%08x%08x%08x%08x%08x" , +readl ((u32 *)uid+1 ), +readl ((u32 *)uid+1 ),readl ((u32 *)uid+2 ), +readl ((u32 *)uid+3 ),readl ((u32 *)uid+4 )); +} + +static struct device *__init db8500_soc_device_init (void ) +{ +const char *soc_id =db8500_read_soc_id (); + +return ux500_soc_device_init (soc_id); +} +/* * This function is called from the board init */ -struct device *__init u8500_init_devices (void ) +struct device *__init u8500_init_devices (void ) { -db8500_add_rtc (NULL ); -db8500_add_gpios (NULL ); -db8500_add_usb (NULL , usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg); +struct device *parent; + + parent =db8500_soc_device_init (); + +db8500_add_rtc (parent); +db8500_add_gpios (parent); +db8500_add_usb (parent, usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg);platform_device_register_simple ("cpufreq-u8500" ,-1 ,NULL ,0 );platform_add_devices (platform_devs,ARRAY_SIZE (platform_devs)); -/* FIXME: Return value to be a real parent. */ -return NULL ; +return parent; }
arch/arm/mach-ux500/cpu.c +75 -0
90 lines not on this page · raw message
arch/arm/mach-ux500/include/mach/db8500-regs.h +3 -0
@@ -161,4 +161,7 @@#define U8500_MODEM_BASE 0xe000000#define U8500_APE_BASE 0x6000000 +/* SoC identification number information */ +#define U8500_BB_UID_BASE (U8500_BACKUPRAM1_BASE + 0xFC0) +#endif
arch/arm/mach-ux500/include/mach/setup.h +2 -0
@@ -27,6 +27,8 @@ extern void __init u5500_sdi_init(struct device *parent);extern void __init db5500_dma_init (struct device *parent); +extern struct device *ux500_soc_device_init (const char *soc_id); +/* We re-use nomadik_timer for this platform */ extern void nmdk_timer_init (void );
Signature · 1 line
1.7.5.4
PATCH 5/6 mach-ux500: move top level platform devices in sysfs to /sys/devices/socX
In reply to Lee JonesAt the request of Arnd Bergmann this patch moves all SoC platform devices found in sysfs from /sys/devices/platform to /sys/devices/soc<SoCNum>/. It is believed as the devices are SoC specific and a /sys/devices/soc node has recently become available, that this would be a more appropriate place to display the data.
--- arch/arm/mach-ux500/board-mop500.c | 12 ++++++++++++ arch/arm/mach-ux500/board-u5500.c | 4 ++++ arch/arm/mach-ux500/cpu-db5500.c | 4 ++++ arch/arm/mach-ux500/cpu-db8500.c | 8 +++++++- arch/arm/mach-ux500/devices-common.c | 13 ++++++++++--- arch/arm/mach-ux500/usb.c | 3 +++ 6 files changed, 40 insertions(+), 4 deletions(-)
arch/arm/mach-ux500/board-mop500.c +12 -0
@@ -610,6 +610,7 @@ static void __init mop500_init_machine(void) {struct device *parent =NULL ;int i2c0_devs; +int i; mop500_gpio_keys[0 ].gpio =GPIO_PROX_SENSOR ;
@@ -617,6 +618,9 @@ static void __init mop500_init_machine(void)mop500_pins_init (); +for (i =0 ; i <ARRAY_SIZE (mop500_platform_devs); i++) + mop500_platform_devs[i]->dev.parent = parent; +platform_add_devices (mop500_platform_devs,ARRAY_SIZE (mop500_platform_devs));
@@ -639,11 +643,15 @@ static void __init snowball_init_machine(void) {struct device *parent =NULL ;int i2c0_devs; +int i; parent =u8500_init_devices ();snowball_pins_init (); +for (i =0 ; i <ARRAY_SIZE (snowball_platform_devs); i++) + snowball_platform_devs[i]->dev.parent = parent; +platform_add_devices (snowball_platform_devs,ARRAY_SIZE (snowball_platform_devs));
@@ -665,6 +673,7 @@ static void __init hrefv60_init_machine(void) {struct device *parent =NULL ;int i2c0_devs; +int i;/* * The HREFv60 board removed a GPIO expander and routed
@@ -677,6 +686,9 @@ static void __init hrefv60_init_machine(void)hrefv60_pins_init (); +for (i =0 ; i <ARRAY_SIZE (mop500_platform_devs); i++) + mop500_platform_devs[i]->dev.parent = parent; +platform_add_devices (mop500_platform_devs,ARRAY_SIZE (mop500_platform_devs));
arch/arm/mach-ux500/board-u5500.c +4 -0
@@ -136,6 +136,7 @@ static void __init u5500_uart_init(struct device *parent)static void __init u5500_init_machine (void ) {struct device *parent =NULL ; +int i; parent =u5500_init_devices ();nmk_config_pins (u5500_pins,ARRAY_SIZE (u5500_pins));
@@ -144,6 +145,9 @@ static void __init u5500_init_machine(void)u5500_sdi_init (parent);u5500_uart_init (parent); +for (i =0 ; i <ARRAY_SIZE (u5500_platform_devices); i++) + u5500_platform_devices[i]->dev.parent = parent; +platform_add_devices (u5500_platform_devices,ARRAY_SIZE (u5500_platform_devices)); }
arch/arm/mach-ux500/cpu-db5500.c +4 -0
@@ -227,6 +227,7 @@ static struct device * __init db5500_soc_device_init(void)struct device *__init u5500_init_devices (void ) {struct device *parent; +int i; parent =db5500_soc_device_init ();
@@ -236,6 +237,9 @@ struct device * __init u5500_init_devices(void)db5500_add_rtc (parent);db5500_add_usb (parent, usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg); +for (i =0 ; i <ARRAY_SIZE (db5500_platform_devs); i++) + db5500_platform_devs[i]->dev.parent = parent; +platform_add_devices (db5500_platform_devs,ARRAY_SIZE (db5500_platform_devs));
arch/arm/mach-ux500/cpu-db8500.c +7 -1
@@ -188,6 +188,7 @@ static struct device * __init db8500_soc_device_init(void)struct device *__init u8500_init_devices (void ) {struct device *parent; +int i; parent =db8500_soc_device_init ();
@@ -195,7 +196,12 @@ struct device * __init u8500_init_devices(void)db8500_add_gpios (parent);db8500_add_usb (parent, usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg); -platform_device_register_simple ("cpufreq-u8500" ,-1 ,NULL ,0 ); +platform_device_register_data (parent, +"cpufreq-u8500" ,-1 ,NULL ,0 ); + +for (i =0 ; i <ARRAY_SIZE (platform_devs); i++) + platform_devs[i]->dev.parent = parent; +platform_add_devices (platform_devs,ARRAY_SIZE (platform_devs));return parent;
arch/arm/mach-ux500/devices-common.c +10 -3
@@ -47,6 +47,8 @@ dbx500_add_amba_device(struct device *parent, const char *name, dev->dev.platform_data = pdata; + dev->dev.parent = parent; + ret =amba_device_register (dev, &iomem_resource);if (ret) {kfree (dev);
@@ -126,9 +128,14 @@ dbx500_add_gpio(struct device *parent, int id, resource_size_t addr, int irq, } }; -return platform_device_register_resndata (NULL ,"gpio" , id, - resources,ARRAY_SIZE (resources), - pdata,sizeof (*pdata)); +return platform_device_register_resndata ( + parent, +"gpio" , + id, + resources, +ARRAY_SIZE (resources), + pdata, +sizeof (*pdata)); } void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
arch/arm/mach-ux500/usb.c +3 -0
@@ -7,6 +7,7 @@#include <linux/platform_device.h> #include <linux/usb/musb.h> #include <linux/dma-mapping.h> +#include <plat/ste_dma40.h> #include <mach/hardware.h> #include <mach/usb.h>
@@ -157,5 +158,7 @@ void ux500_add_usb(struct device *parent, resource_size_t base, int irq,ux500_usb_dma_update_rx_ch_config (dma_rx_cfg);ux500_usb_dma_update_tx_ch_config (dma_tx_cfg); + ux500_musb_device.dev.parent = parent; +platform_device_register (&ux500_musb_device); }
Signature · 1 line
1.7.5.4
PATCH 6/6 mach-ux500: remove intermediary add_platform_device* functions
In reply to Lee JonesThese are no longer required since a 'parent' pointer is now passed to each registering device.
--- arch/arm/mach-ux500/devices-common.c | 53 ---------------------------------- arch/arm/mach-ux500/devices-common.h | 46 ++++++++++++++++------------- arch/arm/mach-ux500/devices-db8500.h | 10 ++++-- 3 files changed, 33 insertions(+), 76 deletions(-)
arch/arm/mach-ux500/devices-common.c +0 -53
@@ -59,59 +59,6 @@ dbx500_add_amba_device(struct device *parent, const char *name, }static struct platform_device * -dbx500_add_platform_device (const char *name,int id,void *pdata, -struct resource *res,int resnum) -{ -struct platform_device *dev; -int ret; - - dev =platform_device_alloc (name, id); -if (!dev) -return ERR_PTR (-ENOMEM ); - - dev->dev.coherent_dma_mask =DMA_BIT_MASK (32 ); - dev->dev.dma_mask = &dev->dev.coherent_dma_mask; - - ret =platform_device_add_resources (dev, res, resnum); -if (ret) - goto out_free; - - dev->dev.platform_data = pdata; - - ret =platform_device_add (dev); -if (ret) - goto out_free; - -return dev; - -out_free: -platform_device_put (dev); -return ERR_PTR (ret); -} - -struct platform_device * -dbx500_add_platform_device_4k1irq (const char *name,int id, -resource_size_t base, -int irq,void *pdata) -{ -struct resource resources[] = { - [0 ] = { - .start = base, - .end = base +SZ_4K -1 , - .flags =IORESOURCE_MEM , - }, - [1 ] = { - .start = irq, - .end = irq, - .flags =IORESOURCE_IRQ , - } - }; - -return dbx500_add_platform_device (name, id, pdata, resources, -ARRAY_SIZE (resources)); -} - -static struct platform_device *dbx500_add_gpio (struct device *parent,int id,resource_size_t addr,int irq,struct nmk_gpio_platform_data *pdata) {
arch/arm/mach-ux500/devices-common.h +26 -20
60 lines not on this page · raw message
arch/arm/mach-ux500/devices-db8500.h +7 -3
@@ -18,9 +18,13 @@ db8500_add_ske_keypad(struct device *parent, struct ske_keypad_platform_data *pdata, size_t size) { -return dbx500_add_platform_device_4k1irq ("nmk-ske-keypad" ,-1 , -U8500_SKE_BASE , -IRQ_DB8500_KB , pdata); +struct resource resources[] = { +DEFINE_RES_MEM (U8500_SKE_BASE ,SZ_4K ), +DEFINE_RES_IRQ (IRQ_DB8500_KB ), + }; + +return platform_device_register_resndata (parent,"nmk-ske-keypad" ,-1 , + resources,2 , pdata, size); } static inline struct amba_device *
Signature · 1 line
1.7.5.4
cover ux500: Export SoC information and some platform clean-up
In reply to Lee JonesQuoted 6 lines · Lee Jones
This patch-set satisfies 4 objectives:
1. Ensures each platform device can specify a suitable parent
2. Provides a bus for SoC devices as a means to export information
3. Allows ux500 to make use of the new SoC bus
4. Cleans up unnecessary complexity from ux500 code
This version looks good to me, I have no further comments right now.
Greg, can you have another look? I think Lee has addressed all of my comments as well as yours.
Linus, does this fit with your plans for migrating to only device-tree based probing for ux500? I guess if this goes in first, you will have to make a few changes so that it keeps working when the devices are put into the dts.
Everyone else, who is planning to use the infrastructure besides ux500?
Arnd
cover ux500: Export SoC information and some platform clean-up
Quoted 2 lines · Arnd Bergmann
Greg, can you have another look? I think Lee has addressed all of my comments as well as yours.
Nevermind, I just saw your replies from Friday, it seems you were already aware of it.
Arnd
cover ux500: Export SoC information and some platform clean-up
In reply to Arnd BergmannQuoted 2 lines · Arnd Bergmann
Linus, does this fit with your plans for migrating to only device-tree based probing for ux500?
Well the SoC registatration (I guess in mach-*/* someplace) needs to be DT compliant by parsing some node too, but that should be some minor thing.
I'm not smart enough to tell whether DT will automagically arrange parenthood between struct device * nodes or if that needs a lot of custom code to work?
Quoted 3 lines
I guess if this goes in
first, you will have to make a few changes so that it keeps working when the devices are put into the dts.
Oh well, that is a bit ahead in time anyway. We need DT support in a plethora of drivers before we're getting anywhere on that. Niklas is the right one to ask I guess...
Quoted 1 line
Everyone else, who is planning to use the infrastructure besides ux500?
I can easily see this being used in the ARM reference designs (Integrator, Versatile, RealView and Versatile Express) some of them I can possibly patch myself even. OMAP has expressed interest in "some way of getting the SoC ID out", and I guess this is the means to that end.
Yours,
Linus Walleij
cover ux500: Export SoC information and some platform clean-up
Quoted 5 lines · Linus Walleij
Quoted 2 lines · Arnd Bergmann
Linus, does this fit with your plans for migrating to only device-tree based probing for ux500?
Quoted 7 lines
Well the SoC registatration (I guess in mach-*/* someplace) needs to be DT compliant by parsing some node too, but that should be some minor thing.
I'm not smart enough to tell whether DT will automagically arrange parenthood between struct device * nodes or if that needs a lot of custom code to work?
Right now, of_platform_populate takes a struct device that is used as the parent for all buses that get probed from the OF device tree. This would need to be integrated with the soc_dev probing in some way, either by letting of_platform_populate call soc_device_register internally and gaining an extra struct soc_device_attribute argument, or by calling of_platform_populate from a platform specific function and passing a device node below the soc_dev into it.
Quoted 7 lines
Quoted 3 lines
I guess if this goes in
first, you will have to make a few changes so that it keeps working when the devices are put into the dts.Oh well, that is a bit ahead in time anyway. We need DT support in a plethora of drivers before we're getting anywhere on that. Niklas is the right one to ask I guess...
Are there really so many driver changes required for this? We would not do it for the on-chip devices at first, so it basically comes down to the the i2c, sdi, spi and uart devices, all of which have bus bindings already. The hardest thing might be the pinmux configuration, but you already know more about the state of that than I do.
Quoted 7 lines
Quoted 1 line
Everyone else, who is planning to use the infrastructure besides ux500?
I can easily see this being used in the ARM reference designs (Integrator, Versatile, RealView and Versatile Express) some of them I can possibly patch myself even. OMAP has expressed interest in "some way of getting the SoC ID out", and I guess this is the means to that end.
Ah, good. Once these patches are merged, we can easily refer anyone to this infrastructure if they try to add a different way of finding a SoC ID.
Arnd
cover ux500: Export SoC information and some platform clean-up
Quoted 47 lines · Arnd Bergmann
Quoted 5 lines · Linus Walleij
Quoted 2 lines · Arnd Bergmann
Linus, does this fit with your plans for migrating to only device-tree based probing for ux500?
Quoted 7 lines
Well the SoC registatration (I guess in mach-*/* someplace) needs to be DT compliant by parsing some node too, but that should be some minor thing.
I'm not smart enough to tell whether DT will automagically arrange parenthood between struct device * nodes or if that needs a lot of custom code to work?
Right now,
of_platform_populatetakes a struct device that is used as the parent for all buses that get probed from the OF device tree. This would need to be integrated with thesoc_devprobing in some way, either by lettingof_platform_populatecallsoc_device_registerinternally and gaining an extra structsoc_device_attributeargument, or by callingof_platform_populatefrom a platform specific function and passing a device node below thesoc_devinto it.Quoted 7 lines
Quoted 3 lines
I guess if this goes in
first, you will have to make a few changes so that it keeps working when the devices are put into the dts.Oh well, that is a bit ahead in time anyway. We need DT support in a plethora of drivers before we're getting anywhere on that. Niklas is the right one to ask I guess...
Are there really so many driver changes required for this? We would not do it for the on-chip devices at first, so it basically comes down to the the i2c, sdi, spi and uart devices, all of which have bus bindings already. The hardest thing might be the pinmux configuration, but you already know more about the state of that than I do.
Quoted 7 lines
Quoted 1 line
Everyone else, who is planning to use the infrastructure besides ux500?
I can easily see this being used in the ARM reference designs (Integrator, Versatile, RealView and Versatile Express) some of them I can possibly patch myself even. OMAP has expressed interest in "some way of getting the SoC ID out", and I guess this is the means to that end.
Quoted 3 lines
Ah, good. Once these patches are merged, we can easily refer anyone to this infrastructure if they try to add a different way of finding a SoC ID.
Okay, so this sounds promising. Which route are the patches likely to take? Will they go up through your SoC tree Arnd?
Kind regards,
Lee
cover ux500: Export SoC information and some platform clean-up
Quoted 8 lines · Lee Jones
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
Everyone else, who is planning to use the infrastructure besides ux500?
I can easily see this being used in the ARM reference designs (Integrator, Versatile, RealView and Versatile Express) some of them I can possibly patch myself even. OMAP has expressed interest in "some way of getting the SoC ID out", and I guess this is the means to that end.
Quoted 6 lines
Quoted 3 lines
Ah, good. Once these patches are merged, we can easily refer anyone to this infrastructure if they try to add a different way of finding a SoC ID.
Okay, so this sounds promising. Which route are the patches likely to take? Will they go up through your SoC tree Arnd?
That's probably the best way. Of course you need to have Acks from Greg (for the bus) and Linus Walleij (for the ux500 stuff) before I can merge them. Linus can decide whether he wants to submit them to me through a pull request from his ux500 tree (with Signed-off-by) or whether I should apply them myself (with Ack).
Arnd
cover ux500: Export SoC information and some platform clean-up
Quoted 16 lines · Arnd Bergmann
Quoted 8 lines · Lee Jones
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
Everyone else, who is planning to use the infrastructure besides ux500?
I can easily see this being used in the ARM reference designs (Integrator, Versatile, RealView and Versatile Express) some of them I can possibly patch myself even. OMAP has expressed interest in "some way of getting the SoC ID out", and I guess this is the means to that end.
Quoted 6 lines
Quoted 3 lines
Ah, good. Once these patches are merged, we can easily refer anyone to this infrastructure if they try to add a different way of finding a SoC ID.
Okay, so this sounds promising. Which route are the patches likely to take? Will they go up through your SoC tree Arnd?
Quoted 6 lines
That's probably the best way. Of course you need to have Acks from Greg (for the bus) and Linus Walleij (for the ux500 stuff) before I can merge them. Linus can decide whether he wants to submit them to me through a pull request from his ux500 tree (with Signed-off-by) or whether I should apply them myself (with Ack).
I'll try to review these again tomorrow...
cover ux500: Export SoC information and some platform clean-up
In reply to Arnd BergmannQuoted 6 lines · Arnd Bergmann
Quoted 2 lines · Lee Jones
Okay, so this sounds promising. Which route are the patches likely to take? Will they go up through your SoC tree Arnd?
That's probably the best way. Of course you need to have Acks from Greg (for the bus) and Linus Walleij (for the ux500 stuff)
Lee, you have my ACK on the Ux500 parts. The bus part I leave for Greg to deal with...
Yours,
Linus Walleij