Root/linux-2.6.32.7_sakc/arch/mips/jz4740/board-sakc.c

1/*
2 * linux/arch/mips/jz4740/board-sakc.c
3 *
4 * SAKC setup routines, based on QI_LB60
5 *
6 * Copyright (c) 2009 Qi Hardware inc.,
7 * Author: Xiangfu Liu <xiangfu@qi-hardware.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 or later
11 * as published by the Free Software Foundation.
12 */
13
14#include <linux/kernel.h>
15#include <linux/init.h>
16#include <linux/gpio.h>
17
18#include <asm/mach-jz4740/board-sakc.h>
19#include <asm/mach-jz4740/platform.h>
20
21#include <linux/input.h>
22//#include <linux/gpio_keys.h>
23#include <linux/mtd/jz4740_nand.h>
24#include <linux/jz4740_fb.h>
25//#include <linux/input/matrix_keypad.h>
26#include <linux/mtd/jz4740_nand.h>
27#include <linux/spi/spi.h>
28#include <linux/spi/spi_gpio.h>
29//#include <linux/power_supply.h>
30//#include <linux/power/jz4740-battery.h>
31//#include <linux/power/gpio-charger.h>
32#include <linux/mmc/jz4740_mmc.h>
33
34
35/* NAND */
36static struct nand_ecclayout sakc_ecclayout_1gb = {
37    .eccbytes = 36,
38    .eccpos = {
39        6, 7, 8, 9, 10, 11, 12, 13,
40        14, 15, 16, 17, 18, 19, 20, 21,
41        22, 23, 24, 25, 26, 27, 28, 29,
42        30, 31, 32, 33, 34, 35, 36, 37,
43        38, 39, 40, 41},
44    .oobfree = {
45        {.offset = 2,
46         .length = 4},
47        {.offset = 42,
48         .length = 22}}
49};
50
51static struct mtd_partition sakc_partitions_1gb[] = {
52    { .name = "NAND BOOT partition",
53      .offset = 0 * 0x100000,
54      .size = 4 * 0x100000,
55     },
56    { .name = "NAND KERNEL partition",
57      .offset = 4 * 0x100000,
58      .size = 4 * 0x100000,
59     },
60    { .name = "NAND ROOTFS partition",
61      .offset = 8 * 0x100000,
62      .size = (504 + 512) * 0x100000,
63     },
64};
65
66static struct nand_ecclayout sakc_ecclayout_2gb = {
67    .eccbytes = 72,
68    .eccpos = {
69        12, 13, 14, 15, 16, 17, 18, 19,
70        20, 21, 22, 23, 24, 25, 26, 27,
71        28, 29, 30, 31, 32, 33, 34, 35,
72        36, 37, 38, 39, 40, 41, 42, 43,
73        44, 45, 46, 47, 48, 49, 50, 51,
74        52, 53, 54, 55, 56, 57, 58, 59,
75        60, 61, 62, 63, 64, 65, 66, 67,
76        68, 69, 70, 71, 72, 73, 74, 75,
77        76, 77, 78, 79, 80, 81, 82, 83},
78    .oobfree = {
79         {.offset = 2,
80         .length = 10},
81        {.offset = 84,
82         .length = 44}}
83};
84
85static struct mtd_partition sakc_partitions_2gb[] = {
86    { .name = "NAND BOOT partition",
87      .offset = 0 * 0x100000,
88      .size = 4 * 0x100000,
89     },
90    { .name = "NAND KERNEL partition",
91      .offset = 4 * 0x100000,
92      .size = 4 * 0x100000,
93     },
94    { .name = "NAND ROOTFS partition",
95      .offset = 8 * 0x100000,
96      .size = (504 + 512 + 1024) * 0x100000,
97     },
98};
99
100static void sakc_nand_ident(struct platform_device *pdev,
101                struct nand_chip *chip,
102                struct mtd_partition **partitions,
103                int *num_partitions)
104{
105    if (chip->page_shift == 12) {
106        chip->ecc.layout = &sakc_ecclayout_2gb;
107        *partitions = sakc_partitions_2gb;
108        *num_partitions = ARRAY_SIZE(sakc_partitions_2gb);
109    } else {
110        chip->ecc.layout = &sakc_ecclayout_1gb;
111        *partitions = sakc_partitions_1gb;
112        *num_partitions = ARRAY_SIZE(sakc_partitions_1gb);
113    }
114}
115
116static struct jz_nand_platform_data sakc_nand_pdata = {
117    .ident_callback = sakc_nand_ident,
118    .busy_gpio = 94,
119};
120
121
122/* Display */
123static struct fb_videomode sakc_video_modes[] = {
124    {
125        .name = "320x240",
126        .xres = 320,
127        .yres = 240,
128        .pixclock = 700000,
129        .left_margin = 140,
130        .right_margin = 273,
131        .upper_margin = 20,
132        .lower_margin = 2,
133        .hsync_len = 1,
134        .vsync_len = 1,
135        .sync = 0,
136        .vmode = FB_VMODE_NONINTERLACED,
137    },
138};
139
140static struct jz4740_fb_platform_data sakc_fb_pdata = {
141    .width = 60,
142    .height = 45,
143    .num_modes = ARRAY_SIZE(sakc_video_modes),
144    .modes = sakc_video_modes,
145    .bpp = 24,
146    .lcd_type = JZ_LCD_TYPE_8BIT_SERIAL,
147};
148
149
150struct spi_gpio_platform_data spigpio_platform_data = {
151    .sck = JZ_GPIO_PORTC(23),
152    .mosi = JZ_GPIO_PORTC(22),
153    .miso = JZ_GPIO_PORTC(22),
154    .num_chipselect = 1,
155};
156
157static struct platform_device spigpio_device = {
158    .name = "spi_gpio",
159    .id = 1,
160    .dev = {
161        .platform_data = &spigpio_platform_data,
162    },
163};
164
165static struct spi_board_info sakc_spi_board_info[] = {
166    {
167        .modalias = "gpm940b0",
168        .controller_data = (void*)JZ_GPIO_PORTC(21),
169        .chip_select = 0,
170        .bus_num = 1,
171        .max_speed_hz = 30 * 1000,
172    },
173};
174
175/* MMC */
176
177static struct jz4740_mmc_platform_data sakc_mmc_pdata = {
178    .gpio_card_detect = JZ_GPIO_PORTC(27),
179    .gpio_read_only = -1,
180    .gpio_power = -1,
181    .power_active_low = 1,
182    .data_1bit = 1,
183};
184
185static struct platform_device *jz_platform_devices[] __initdata = {
186    &jz4740_usb_ohci_device,
187    &jz4740_usb_gdt_device,
188    &jz4740_mmc_device,
189    &jz4740_nand_device,
190    &spigpio_device,
191    &jz4740_framebuffer_device,
192    &jz4740_i2s_device,
193    &jz4740_codec_device,
194    &jz4740_rtc_device,
195    &jz4740_adc_device,
196};
197
198static void __init board_gpio_setup(void)
199{
200    /* We only need to enable/disable pullup here for pins used in generic
201     * drivers. Everything else is done by the drivers themselfs. */
202    jz_gpio_disable_pullup(GPIO_SD_CD_N);
203}
204
205static int __init sakc_init_platform_devices(void)
206{
207    jz4740_framebuffer_device.dev.platform_data = &sakc_fb_pdata;
208    jz4740_nand_device.dev.platform_data = &sakc_nand_pdata;
209    jz4740_mmc_device.dev.platform_data = &sakc_mmc_pdata;
210
211    spi_register_board_info(sakc_spi_board_info,
212                ARRAY_SIZE(sakc_spi_board_info));
213
214    return platform_add_devices(jz_platform_devices,
215                    ARRAY_SIZE(jz_platform_devices));
216
217}
218extern int jz_gpiolib_init(void);
219extern int jz_init_clocks(unsigned long extal);
220
221static __init int board_sakc(char *str)
222{
223    sakc_mmc_pdata.card_detect_active_low = 1;
224
225    return 1;
226}
227
228__setup("sakc", board_sakc);
229
230static int __init sakc_board_setup(void)
231{
232    printk("Qi Hardware JZ4725 SAKC setup\n");
233    if (jz_gpiolib_init())
234        panic("Failed to initalize jz gpio\n");
235    jz_init_clocks(12000000);
236
237    board_gpio_setup();
238
239    if (sakc_init_platform_devices())
240        panic("Failed to initalize platform devices\n");
241
242    return 0;
243}
244
245arch_initcall(sakc_board_setup);
246

Archive Download this file

Branches:
master



interactive