Yusuke Goda | 04e917b | 2008-06-06 17:03:23 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Renesas - AP-325RXA |
| 3 | * (Compatible with Algo System ., LTD. - AP-320A) |
| 4 | * |
| 5 | * Copyright (C) 2008 Renesas Solutions Corp. |
| 6 | * Author : Yusuke Goda <goda.yuske@renesas.com> |
| 7 | * |
| 8 | * This file is subject to the terms and conditions of the GNU General Public |
| 9 | * License. See the file "COPYING" in the main directory of this archive |
| 10 | * for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/device.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/mtd/physmap.h> |
| 17 | #include <linux/delay.h> |
Magnus Damm | 026953d | 2008-07-05 12:32:44 +0900 | [diff] [blame] | 18 | #include <linux/i2c.h> |
Magnus Damm | 6968980 | 2008-07-28 19:07:04 +0900 | [diff] [blame^] | 19 | #include <linux/delay.h> |
| 20 | #include <asm/sh_mobile_lcdc.h> |
Yusuke Goda | 04e917b | 2008-06-06 17:03:23 +0900 | [diff] [blame] | 21 | #include <asm/io.h> |
Magnus Damm | 6968980 | 2008-07-28 19:07:04 +0900 | [diff] [blame^] | 22 | #include <asm/clock.h> |
Yusuke Goda | 04e917b | 2008-06-06 17:03:23 +0900 | [diff] [blame] | 23 | |
| 24 | static struct resource smc9118_resources[] = { |
| 25 | [0] = { |
| 26 | .start = 0xb6080000, |
| 27 | .end = 0xb60fffff, |
| 28 | .flags = IORESOURCE_MEM, |
| 29 | }, |
| 30 | [1] = { |
| 31 | .start = 35, |
| 32 | .end = 35, |
| 33 | .flags = IORESOURCE_IRQ, |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | static struct platform_device smc9118_device = { |
| 38 | .name = "smc911x", |
| 39 | .id = -1, |
| 40 | .num_resources = ARRAY_SIZE(smc9118_resources), |
| 41 | .resource = smc9118_resources, |
| 42 | }; |
| 43 | |
| 44 | static struct mtd_partition ap325rxa_nor_flash_partitions[] = { |
| 45 | { |
| 46 | .name = "uboot", |
| 47 | .offset = 0, |
| 48 | .size = (1 * 1024 * 1024), |
| 49 | .mask_flags = MTD_WRITEABLE, /* Read-only */ |
| 50 | }, { |
| 51 | .name = "kernel", |
| 52 | .offset = MTDPART_OFS_APPEND, |
| 53 | .size = (2 * 1024 * 1024), |
| 54 | }, { |
| 55 | .name = "other", |
| 56 | .offset = MTDPART_OFS_APPEND, |
| 57 | .size = MTDPART_SIZ_FULL, |
| 58 | }, |
| 59 | }; |
| 60 | |
| 61 | static struct physmap_flash_data ap325rxa_nor_flash_data = { |
| 62 | .width = 2, |
| 63 | .parts = ap325rxa_nor_flash_partitions, |
| 64 | .nr_parts = ARRAY_SIZE(ap325rxa_nor_flash_partitions), |
| 65 | }; |
| 66 | |
| 67 | static struct resource ap325rxa_nor_flash_resources[] = { |
| 68 | [0] = { |
| 69 | .name = "NOR Flash", |
| 70 | .start = 0x00000000, |
| 71 | .end = 0x00ffffff, |
| 72 | .flags = IORESOURCE_MEM, |
| 73 | } |
| 74 | }; |
| 75 | |
| 76 | static struct platform_device ap325rxa_nor_flash_device = { |
| 77 | .name = "physmap-flash", |
| 78 | .resource = ap325rxa_nor_flash_resources, |
| 79 | .num_resources = ARRAY_SIZE(ap325rxa_nor_flash_resources), |
| 80 | .dev = { |
| 81 | .platform_data = &ap325rxa_nor_flash_data, |
| 82 | }, |
| 83 | }; |
| 84 | |
Magnus Damm | 6968980 | 2008-07-28 19:07:04 +0900 | [diff] [blame^] | 85 | #define FPGA_LCDREG 0xB4100180 |
| 86 | #define FPGA_BKLREG 0xB4100212 |
| 87 | #define FPGA_LCDREG_VAL 0x0018 |
| 88 | #define PORT_PHCR 0xA405010E |
| 89 | #define PORT_PLCR 0xA4050114 |
| 90 | #define PORT_PMCR 0xA4050116 |
| 91 | #define PORT_PRCR 0xA405011C |
| 92 | #define PORT_HIZCRA 0xA4050158 |
| 93 | #define PORT_PSCR 0xA405011E |
| 94 | #define PORT_PSDR 0xA405013E |
| 95 | |
| 96 | static void ap320_wvga_power_on(void *board_data) |
| 97 | { |
| 98 | msleep(100); |
| 99 | |
| 100 | /* ASD AP-320/325 LCD ON */ |
| 101 | ctrl_outw(FPGA_LCDREG_VAL, FPGA_LCDREG); |
| 102 | |
| 103 | /* backlight */ |
| 104 | ctrl_outw((ctrl_inw(PORT_PSCR) & ~0x00C0) | 0x40, PORT_PSCR); |
| 105 | ctrl_outb(ctrl_inb(PORT_PSDR) & ~0x08, PORT_PSDR); |
| 106 | ctrl_outw(0x100, FPGA_BKLREG); |
| 107 | } |
| 108 | |
| 109 | static struct sh_mobile_lcdc_info lcdc_info = { |
| 110 | .clock_source = LCDC_CLK_EXTERNAL, |
| 111 | .ch[0] = { |
| 112 | .chan = LCDC_CHAN_MAINLCD, |
| 113 | .bpp = 16, |
| 114 | .interface_type = RGB18, |
| 115 | .clock_divider = 1, |
| 116 | .lcd_cfg = { |
| 117 | .name = "LB070WV1", |
| 118 | .xres = 800, |
| 119 | .yres = 480, |
| 120 | .left_margin = 40, |
| 121 | .right_margin = 160, |
| 122 | .hsync_len = 8, |
| 123 | .upper_margin = 63, |
| 124 | .lower_margin = 80, |
| 125 | .vsync_len = 1, |
| 126 | .sync = 0, /* hsync and vsync are active low */ |
| 127 | }, |
| 128 | .board_cfg = { |
| 129 | .display_on = ap320_wvga_power_on, |
| 130 | }, |
| 131 | } |
| 132 | }; |
| 133 | |
| 134 | static struct resource lcdc_resources[] = { |
| 135 | [0] = { |
| 136 | .name = "LCDC", |
| 137 | .start = 0xfe940000, /* P4-only space */ |
| 138 | .end = 0xfe941fff, |
| 139 | .flags = IORESOURCE_MEM, |
| 140 | }, |
| 141 | }; |
| 142 | |
| 143 | static struct platform_device lcdc_device = { |
| 144 | .name = "sh_mobile_lcdc_fb", |
| 145 | .num_resources = ARRAY_SIZE(lcdc_resources), |
| 146 | .resource = lcdc_resources, |
| 147 | .dev = { |
| 148 | .platform_data = &lcdc_info, |
| 149 | }, |
| 150 | }; |
| 151 | |
Yusuke Goda | 04e917b | 2008-06-06 17:03:23 +0900 | [diff] [blame] | 152 | static struct platform_device *ap325rxa_devices[] __initdata = { |
| 153 | &smc9118_device, |
Magnus Damm | 6968980 | 2008-07-28 19:07:04 +0900 | [diff] [blame^] | 154 | &ap325rxa_nor_flash_device, |
| 155 | &lcdc_device, |
Yusuke Goda | 04e917b | 2008-06-06 17:03:23 +0900 | [diff] [blame] | 156 | }; |
| 157 | |
Magnus Damm | 026953d | 2008-07-05 12:32:44 +0900 | [diff] [blame] | 158 | static struct i2c_board_info __initdata ap325rxa_i2c_devices[] = { |
| 159 | }; |
| 160 | |
Yusuke Goda | 04e917b | 2008-06-06 17:03:23 +0900 | [diff] [blame] | 161 | static int __init ap325rxa_devices_setup(void) |
| 162 | { |
Magnus Damm | 6968980 | 2008-07-28 19:07:04 +0900 | [diff] [blame^] | 163 | clk_always_enable("mstp200"); /* LCDC */ |
| 164 | |
Magnus Damm | 026953d | 2008-07-05 12:32:44 +0900 | [diff] [blame] | 165 | i2c_register_board_info(0, ap325rxa_i2c_devices, |
| 166 | ARRAY_SIZE(ap325rxa_i2c_devices)); |
| 167 | |
Yusuke Goda | 04e917b | 2008-06-06 17:03:23 +0900 | [diff] [blame] | 168 | return platform_add_devices(ap325rxa_devices, |
| 169 | ARRAY_SIZE(ap325rxa_devices)); |
| 170 | } |
| 171 | device_initcall(ap325rxa_devices_setup); |
| 172 | |
Yusuke Goda | 04e917b | 2008-06-06 17:03:23 +0900 | [diff] [blame] | 173 | static void __init ap325rxa_setup(char **cmdline_p) |
| 174 | { |
Magnus Damm | 6968980 | 2008-07-28 19:07:04 +0900 | [diff] [blame^] | 175 | /* LCDC configuration */ |
| 176 | ctrl_outw(ctrl_inw(PORT_PHCR) & ~0xffff, PORT_PHCR); |
| 177 | ctrl_outw(ctrl_inw(PORT_PLCR) & ~0xffff, PORT_PLCR); |
| 178 | ctrl_outw(ctrl_inw(PORT_PMCR) & ~0xffff, PORT_PMCR); |
| 179 | ctrl_outw(ctrl_inw(PORT_PRCR) & ~0x03ff, PORT_PRCR); |
| 180 | ctrl_outw(ctrl_inw(PORT_HIZCRA) & ~0x01C0, PORT_HIZCRA); |
Yusuke Goda | 04e917b | 2008-06-06 17:03:23 +0900 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | static struct sh_machine_vector mv_ap325rxa __initmv = { |
| 184 | .mv_name = "AP-325RXA", |
| 185 | .mv_setup = ap325rxa_setup, |
| 186 | }; |