From: Magnus D. <mag...@gm...> - 2007-10-10 04:34:40
|
sh: move sm501 serial port platform data into sm501.c This patch moves the platform data for the 8250 block in the sm501 from the board specific code to the sm501 specific mfd driver. This seems to work well for now on r2d but in the future we should move the interrupt demux code as well. Signed-off-by: Magnus Damm <da...@ig...> --- arch/sh/boards/renesas/rts7751r2d/setup.c | 61 ++++++++++++++------------ drivers/mfd/sm501.c | 67 +++++++++++++++++++++-------- include/linux/sm501.h | 1 3 files changed, 84 insertions(+), 45 deletions(-) --- 0001/arch/sh/boards/renesas/rts7751r2d/setup.c +++ work/arch/sh/boards/renesas/rts7751r2d/setup.c 2007-10-10 13:01:18.000000000 +0900 @@ -11,8 +11,8 @@ #include <linux/init.h> #include <linux/platform_device.h> #include <linux/pata_platform.h> -#include <linux/serial_8250.h> #include <linux/sm501.h> +#include <linux/sm501-regs.h> #include <linux/pm.h> #include <asm/machvec.h> #include <asm/rts7751r2d.h> @@ -88,28 +88,6 @@ static struct platform_device heartbeat_ .resource = heartbeat_resources, }; -#ifdef CONFIG_MFD_SM501 -static struct plat_serial8250_port uart_platform_data[] = { - { - .membase = (void __iomem *)VOYAGER_UART_BASE, - .mapbase = VOYAGER_UART_BASE, - .iotype = UPIO_MEM, - .irq = IRQ_SM501_U0, - .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, - .regshift = 2, - .uartclk = (9600 * 16), - }, - { 0 }, -}; - -static struct platform_device uart_device = { - .name = "serial8250", - .id = PLAT8250_DEV_PLATFORM, - .dev = { - .platform_data = uart_platform_data, - }, -}; - static struct resource sm501_resources[] = { [0] = { .start = 0x10000000, @@ -127,20 +105,47 @@ static struct resource sm501_resources[] }, }; +#define MHZ (1000 * 1000) + +static struct sm501_initdata r2d_sm501_initdata = { + .gpio_high = { + .set = 0x3F000000, /* 24bit panel */ + .mask = 0x0, + }, + .misc_timing = { + .set = 0x010100, /* SDRAM timing */ + .mask = 0x1F1F00, + }, + .misc_control = { + .set = SM501_MISC_PNL_24BIT, + .mask = 0, + }, + + .devices = SM501_USE_UART0, + + /* Errata AB-3 says that 72MHz is the fastest available + * for 33MHZ PCI with proper bus-mastering operation */ + + .mclk = 72 * MHZ, + .m1xclk = 144 * MHZ, +}; + +static struct sm501_platdata r2d_sm501_platdata = { + .init = &r2d_sm501_initdata, +}; + static struct platform_device sm501_device = { .name = "sm501", .id = -1, .num_resources = ARRAY_SIZE(sm501_resources), .resource = sm501_resources, + .dev = { + .platform_data = &r2d_sm501_platdata, + }, }; -#endif /* CONFIG_MFD_SM501 */ - static struct platform_device *rts7751r2d_devices[] __initdata = { -#ifdef CONFIG_MFD_SM501 - &uart_device, &sm501_device, -#endif &heartbeat_device, }; --- 0001/drivers/mfd/sm501.c +++ work/drivers/mfd/sm501.c 2007-10-10 12:57:20.000000000 +0900 @@ -22,6 +22,7 @@ #include <linux/sm501.h> #include <linux/sm501-regs.h> +#include <linux/serial_8250.h> #include <asm/io.h> @@ -651,13 +652,14 @@ static void sm501_device_release(struct */ static struct platform_device * -sm501_create_subdev(struct sm501_devdata *sm, - char *name, unsigned int res_count) +sm501_create_subdev(struct sm501_devdata *sm, char *name, + unsigned int res_count, unsigned int platform_data_size) { struct sm501_device *smdev; smdev = kzalloc(sizeof(struct sm501_device) + - sizeof(struct resource) * res_count, GFP_KERNEL); + (sizeof(struct resource) * res_count) + + platform_data_size, GFP_KERNEL); if (!smdev) return NULL; @@ -665,11 +667,15 @@ sm501_create_subdev(struct sm501_devdata smdev->pdev.name = name; smdev->pdev.id = sm->pdev_id; - smdev->pdev.resource = (struct resource *)(smdev+1); - smdev->pdev.num_resources = res_count; - smdev->pdev.dev.parent = sm->dev; + if (res_count) { + smdev->pdev.resource = (struct resource *)(smdev+1); + smdev->pdev.num_resources = res_count; + } + if (platform_data_size) + smdev->pdev.dev.platform_data = (void *)(smdev+1); + return &smdev->pdev; } @@ -757,7 +763,7 @@ static int sm501_register_usbhost(struct { struct platform_device *pdev; - pdev = sm501_create_subdev(sm, "sm501-usb", 3); + pdev = sm501_create_subdev(sm, "sm501-usb", 3, 0); if (!pdev) return -ENOMEM; @@ -768,12 +774,37 @@ static int sm501_register_usbhost(struct return sm501_register_device(sm, pdev); } +static int sm501_register_serial(struct sm501_devdata *sm, + unsigned int offset, int irq) +{ + struct platform_device *pdev; + struct plat_serial8250_port *uart_data; + + pdev = sm501_create_subdev(sm, "serial8250", 0, + sizeof(struct plat_serial8250_port) * 2); + if (!pdev) + return -ENOMEM; + + uart_data = pdev->dev.platform_data; + uart_data->membase = sm->regs + offset; + uart_data->mapbase = sm->io_res->start + offset; + uart_data->iotype = UPIO_MEM; + uart_data->irq = irq ? irq : sm->irq; + uart_data->flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST; + uart_data->regshift = 2; + uart_data->uartclk = (9600 * 16); + + pdev->id = PLAT8250_DEV_PLATFORM; + + return sm501_register_device(sm, pdev); +} + static int sm501_register_display(struct sm501_devdata *sm, resource_size_t *mem_avail) { struct platform_device *pdev; - pdev = sm501_create_subdev(sm, "sm501-fb", 4); + pdev = sm501_create_subdev(sm, "sm501-fb", 4, 0); if (!pdev) return -ENOMEM; @@ -891,6 +922,7 @@ static unsigned int sm501_mem_local[] = static int sm501_init_dev(struct sm501_devdata *sm) { + struct sm501_initdata *idata; resource_size_t mem_avail; unsigned long dramctrl; unsigned long devid; @@ -924,15 +956,16 @@ static int sm501_init_dev(struct sm501_d /* check to see if we have some device initialisation */ - if (sm->platdata) { - struct sm501_platdata *pdata = sm->platdata; - - if (pdata->init) { - sm501_init_regs(sm, sm->platdata->init); - - if (pdata->init->devices & SM501_USE_USB_HOST) - sm501_register_usbhost(sm, &mem_avail); - } + idata = sm->platdata ? sm->platdata->init : NULL; + if (idata) { + sm501_init_regs(sm, idata); + + if (idata->devices & SM501_USE_USB_HOST) + sm501_register_usbhost(sm, &mem_avail); + if (idata->devices & SM501_USE_UART0) + sm501_register_serial(sm, 0x30000, idata->irq[12]); + if (idata->devices & SM501_USE_UART1) + sm501_register_serial(sm, 0x30020, idata->irq[13]); } ret = sm501_check_clocks(sm); --- 0001/include/linux/sm501.h +++ work/include/linux/sm501.h 2007-10-10 12:19:19.000000000 +0900 @@ -138,6 +138,7 @@ struct sm501_initdata { unsigned long devices; unsigned long mclk; /* non-zero to modify */ unsigned long m1xclk; /* non-zero to modify */ + int irq[32]; }; /* sm501_init_gpio |