From af7547573622173cd6e1aac9e288fc50165e5a47 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 22 Jan 2010 12:24:26 +0100 Subject: Instead of adding a probe_completed callback to each an every driver install a bus notify handler and handle this in a generic way. --- arch/arm/mach-s3c2442/mach-gta02.c | 74 +++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 9 deletions(-) (limited to 'arch/arm/mach-s3c2442/mach-gta02.c') diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index 841dff64e3f..cdd569885cd 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -713,7 +713,6 @@ static void gta02_jbt6k74_probe_completed(struct device *dev) } const struct jbt6k74_platform_data jbt6k74_pdata = { - .probe_completed = gta02_jbt6k74_probe_completed, .gpio_reset = GTA02_GPIO_GLAMO(4), }; @@ -861,12 +860,6 @@ struct platform_device gta02_platform_bat = { /* HDQ */ -static void gta02_hdq_attach_child_devices(struct device *parent_device) -{ - bq27000_battery_device.dev.parent = parent_device; - platform_device_register(&bq27000_battery_device); -} - static void gta02_hdq_gpio_direction_out(void) { s3c2410_gpio_cfgpin(GTA02v5_GPIO_HDQ, S3C2410_GPIO_OUTPUT); @@ -982,7 +975,6 @@ static struct platform_device gta02_pwm_leds_device = { }; struct hdq_platform_data gta02_hdq_platform_data = { - .attach_child_devices = gta02_hdq_attach_child_devices, .gpio_dir_out = gta02_hdq_gpio_direction_out, .gpio_dir_in = gta02_hdq_gpio_direction_in, .gpio_set = gta02_hdq_gpio_set_value, @@ -991,7 +983,6 @@ struct hdq_platform_data gta02_hdq_platform_data = { .enable_fiq = gta02_fiq_enable, .disable_fiq = gta02_fiq_disable, .kick_fiq = gta02_fiq_kick, - }; struct platform_device gta02_hdq_device = { @@ -1074,6 +1065,71 @@ static void gta02_poweroff(void) pcf50633_reg_set_bit_mask(gta02_pcf, PCF50633_REG_OOCSHDWN, 1, 1); } + +struct gta02_device_children { + const char *dev_name; + size_t num_children; + struct platform_device **children; + void (*probed_callback)(struct device *dev); +}; + +static struct platform_device* gta02_hdq_children[] = { + &bq27000_battery_device, +}; + +static struct gta02_device_children gta02_device_children[] = { + { + .dev_name = "hdq.0", + .num_children = 1, + .children = gta02_hdq_children, + }, + { + .dev_name = "spi2.0", + .probed_callback = gta02_jbt6k74_probe_completed, + }, +}; + +static int gta02_add_child_devices(struct device *parent, + struct platform_device **children, + size_t num_children) +{ + size_t i; + + for (i = 0; i < num_children; ++i) + children[i]->dev.parent = parent; + + return platform_add_devices(children, num_children); +} + +static int gta02_device_registered(struct notifier_block *block, + unsigned long action, void *data) +{ + struct device *dev = data; + const char *devname = dev_name(dev); + size_t i; + + if (action != BUS_NOTIFY_BOUND_DRIVER) + return 0; + + for (i = 0; i < ARRAY_SIZE(gta02_device_children); ++i) { + if (strcmp(devname, gta02_device_children[i].dev_name) == 0) { + gta02_add_child_devices(dev, gta02_device_children[i].children, + gta02_device_children[i].num_children); + + if (gta02_device_children[i].probed_callback) + gta02_device_children[i].probed_callback(dev); + break; + } + } + + return 0; +} + +static struct notifier_block gta02_device_register_notifier = { + .notifier_call = gta02_device_registered, + .priority = INT_MAX, +}; + /* On hardware rev 5 and earlier the leds are missing a resistor and reading * from their gpio pins will always return 0, so we have to shadow the * led states software */ -- cgit v1.2.3 From 3c4a1161634e1b425c9f1154b1935c6b9f422394 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 22 Jan 2010 12:59:41 +0100 Subject: gta02: Configure pcf50633-gpio device and add a regulator device which represents the power switch in front of the gsm modem. --- arch/arm/mach-s3c2442/mach-gta02.c | 53 +++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'arch/arm/mach-s3c2442/mach-gta02.c') diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index cdd569885cd..eb41ad901cf 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -305,6 +305,39 @@ static struct platform_device gta02_pm_wlan_dev = { .name = "gta02-pm-wlan", }; +static struct regulator_consumer_supply gsm_supply_consumer = { + .dev = >a02_pm_gsm_dev.dev, + .supply = "GSM", +}; + +static struct regulator_init_data gsm_supply_init_data = { + .constraints = { + .min_uV = 3700000, + .max_uV = 3700000, + .valid_modes_mask = REGULATOR_MODE_NORMAL, + .valid_ops_mask = REGULATOR_CHANGE_STATUS, + }, + .num_consumer_supplies = 1, + .consumer_supplies = &gsm_supply_consumer, +}; + +static struct fixed_voltage_config gsm_supply_config = { + .supply_name = "GSM", + .microvolts = 3700000, + .gpio = GTA02_GPIO_PCF(PCF50633_GPIO2), + .enable_high = 1, + .init_data = &gsm_supply_init_data, +}; + +static struct platform_device gta02_gsm_supply_device = { + .name = "reg-fixed-voltage", + .id = 1, + .dev = { + .platform_data = &gsm_supply_config, + }, +}; + + #ifdef CONFIG_CHARGER_PCF50633 /* * On GTA02 the 1A charger features a 48K resistor to 0V on the ID pin. @@ -343,7 +376,7 @@ gta02_configure_pmu_for_charger(struct pcf50633 *pcf, void *unused, int res) * Sanity - stop GPO driving out now that we have a 1A charger * GPO controls USB Host power generation on GTA02 */ - pcf50633_gpio_set(pcf, PCF50633_GPO, 0); + /*pcf50633_gpio_set(pcf, PCF50633_GPO, 0);*/ ma = 1000; } else @@ -1073,6 +1106,14 @@ struct gta02_device_children { void (*probed_callback)(struct device *dev); }; +static struct platform_device* gta02_pcf50633_gpio_children[] = { + >a02_gsm_supply_device, +}; + +static struct platform_device* gta02_gsm_supply_children[] = { + >a02_pm_gsm_dev, +}; + static struct platform_device* gta02_hdq_children[] = { &bq27000_battery_device, }; @@ -1087,6 +1128,16 @@ static struct gta02_device_children gta02_device_children[] = { .dev_name = "spi2.0", .probed_callback = gta02_jbt6k74_probe_completed, }, + { + .dev_name = "pcf50633-gpio", + .num_children = 1, + .children = gta02_pcf50633_gpio_children, + }, + { + .dev_name = "reg-fixed-voltage.1", + .num_children = 1, + .children = gta02_gsm_supply_children, + } }; static int gta02_add_child_devices(struct device *parent, -- cgit v1.2.3 From 0f934952e071d73916be967d44a150c408edf2cb Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 22 Jan 2010 13:46:37 +0100 Subject: gta02: Those changes were lost during merging... --- arch/arm/mach-s3c2442/mach-gta02.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'arch/arm/mach-s3c2442/mach-gta02.c') diff --git a/arch/arm/mach-s3c2442/mach-gta02.c b/arch/arm/mach-s3c2442/mach-gta02.c index eb41ad901cf..3e0b12ac45d 100644 --- a/arch/arm/mach-s3c2442/mach-gta02.c +++ b/arch/arm/mach-s3c2442/mach-gta02.c @@ -51,6 +51,7 @@ #include #include +#include #include #include @@ -510,6 +511,8 @@ struct pcf50633_platform_data gta02_pcf_pdata = { .backlight_data = >a02_backlight_data, + .gpio_base = GTA02_GPIO_PCF_BASE, + .reg_init_data = { [PCF50633_REGULATOR_AUTO] = { .constraints = { @@ -1055,7 +1058,6 @@ static struct platform_device *gta02_devices[] __initdata = { >a02_pwm_leds_device, >a02_pm_gps_dev, >a02_pm_bt_dev, - >a02_pm_gsm_dev, >a02_pm_wlan_dev, &s3c_device_adc, }; @@ -1275,6 +1277,9 @@ static void __init gta02_machine_init(void) /* Set the panic callback to make AUX LED blink at ~5Hz. */ panic_blink = gta02_panic_blink; + bus_register_notifier(&platform_bus_type, >a02_device_register_notifier); + bus_register_notifier(&spi_bus_type, >a02_device_register_notifier); + gta02_hijack_gpb(); gta02_request_gpios(); -- cgit v1.2.3