2 * linux/arch/mips/jz4740/board-516.c
4 * JZ4740 n516 board setup routines.
6 * Copyright (c) 2009, Yauhen Kharuzhy <jekhor@gmail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #include <linux/init.h>
15 #include <linux/sched.h>
16 #include <linux/ioport.h>
18 #include <linux/console.h>
19 #include <linux/delay.h>
20 #include <linux/i2c.h>
21 #include <linux/platform_device.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mmc/jz4740_mmc.h>
24 #include <linux/mtd/jz4740_nand.h>
25 #include <linux/leds.h>
27 #include <linux/power_supply.h>
28 #include <linux/power/gpio-charger.h>
30 #include <linux/i2c.h>
31 #include <linux/i2c-gpio.h>
33 #include <asm/mach-jz4740/board-n516.h>
34 #include <asm/mach-jz4740/platform.h>
38 static long n516_panic_blink(long time
)
40 gpio_set_value(GPIO_LED_ENABLE
, 1);
42 gpio_set_value(GPIO_LED_ENABLE
, 0);
48 static void __init
board_gpio_setup(void)
50 /* jz_gpio_enable_pullup(JZ_GPIO_PORTD(23));
51 jz_gpio_enable_pullup(JZ_GPIO_PORTD(24));*/
54 static struct i2c_gpio_platform_data n516_i2c_pdata
= {
55 .sda_pin
= JZ_GPIO_PORTD(23),
56 .scl_pin
= JZ_GPIO_PORTD(24),
61 static struct platform_device n516_i2c_device
= {
65 .platform_data
= &n516_i2c_pdata
,
69 static const struct i2c_board_info n516_i2c_board_info
[] = {
80 static struct jz4740_mmc_platform_data n516_mmc_pdata
= {
81 .gpio_card_detect
= GPIO_SD_CD_N
,
82 .card_detect_active_low
= 1,
84 .gpio_power
= GPIO_SD_VCC_EN_N
,
85 .power_active_low
= 1,
88 static struct gpio_led n516_leds
[] = {
90 .name
= "n516:blue:power",
91 .gpio
= GPIO_LED_ENABLE
,
92 .default_state
= LEDS_GPIO_DEFSTATE_ON
,
93 .default_trigger
= "nand-disk",
97 static struct gpio_led_platform_data n516_leds_pdata
= {
99 .num_leds
= ARRAY_SIZE(n516_leds
),
102 static struct platform_device n516_leds_device
= {
106 .platform_data
= &n516_leds_pdata
,
110 static struct mtd_partition n516_partitions
[] = {
111 { .name
= "NAND BOOT partition",
112 .offset
= 0 * 0x100000,
113 .size
= 4 * 0x100000,
115 { .name
= "NAND KERNEL partition",
116 .offset
= 4 * 0x100000,
117 .size
= 4 * 0x100000,
119 { .name
= "NAND ROOTFS partition",
120 .offset
= 8 * 0x100000,
121 .size
= 504 * 0x100000,
125 static struct nand_ecclayout n516_ecclayout
= {
128 6, 7, 8, 9, 10, 11, 12, 13, 14,
129 15, 16, 17, 18, 19, 20, 21, 22, 23,
130 24, 25, 26, 27, 28, 29, 30, 31, 32,
131 33, 34, 35, 36, 37, 38, 39, 40, 41,
140 static struct jz_nand_platform_data n516_nand_pdata
= {
141 .ecc_layout
= &n516_ecclayout
,
142 .partitions
= n516_partitions
,
143 .num_partitions
= ARRAY_SIZE(n516_partitions
),
147 static char *n516_batteries
[] = {
151 static struct gpio_charger_platform_data n516_charger_pdata
= {
153 .type
= POWER_SUPPLY_TYPE_USB
,
154 .gpio
= GPIO_USB_DETECT
,
155 .gpio_active_low
= 1,
156 .batteries
= n516_batteries
,
157 .num_batteries
= ARRAY_SIZE(n516_batteries
),
160 static struct platform_device n516_charger_device
= {
161 .name
= "gpio-charger",
163 .platform_data
= &n516_charger_pdata
,
167 static struct platform_device
*n516_devices
[] __initdata
= {
172 &jz4740_codec_device
,
174 &jz4740_usb_gdt_device
,
176 &n516_charger_device
,
179 struct jz4740_clock_board_data jz4740_clock_bdata
= {
180 .ext_rate
= 12000000,
184 extern int jz_gpiolib_init(void);
186 static int n516_setup_platform(void)
188 if (jz_gpiolib_init())
189 panic("Failed to initalize jz gpio\n");
194 panic_blink
= n516_panic_blink
;
195 i2c_register_board_info(0, n516_i2c_board_info
, ARRAY_SIZE(n516_i2c_board_info
));
196 jz4740_mmc_device
.dev
.platform_data
= &n516_mmc_pdata
;
197 jz4740_nand_device
.dev
.platform_data
= &n516_nand_pdata
;
199 return platform_add_devices(n516_devices
, ARRAY_SIZE(n516_devices
));
201 arch_initcall(n516_setup_platform
);