Root/arch/mips/jz47xx/jz4740/board-n516.c

Source at commit fad288aff22be8618aeb6baa5c980f721226a5e1 created 9 years 4 months ago.
By Peter Zotov, MIPS: JZ47xx: Fix a few naming issues.
1/*
2 * linux/arch/mips/jz4740/board-516.c
3 *
4 * JZ4740 n516 board setup routines.
5 *
6 * Copyright (c) 2009, Yauhen Kharuzhy <jekhor@gmail.com>
7 *
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.
12 */
13
14#include <linux/init.h>
15#include <linux/sched.h>
16#include <linux/ioport.h>
17#include <linux/mm.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/leds.h>
24
25#include <linux/power_supply.h>
26#include <linux/power/gpio-charger.h>
27
28#include <linux/i2c.h>
29
30#include <asm/mach-jz4740/jz4740_mmc.h>
31#include <asm/mach-jz4740/jz4740_nand.h>
32
33#include <asm/mach-jz4740/board-n516.h>
34#include <asm/mach-jz4740/platform.h>
35
36#include "../clock.h"
37
38static long n516_panic_blink(int state)
39{
40    gpio_set_value(GPIO_LED_ENABLE, state ? 1 : 0);
41    return 0;
42}
43
44static void __init board_gpio_setup(void)
45{
46/* jz_gpio_enable_pullup(JZ_GPIO_PORTD(23));
47    jz_gpio_enable_pullup(JZ_GPIO_PORTD(24));*/
48}
49
50static const struct i2c_board_info n516_i2c_board_info[] = {
51    {
52        .type = "LPC524",
53        .addr = 0x54,
54    },
55    {
56        .type = "lm75a",
57        .addr = 0x48,
58    }
59};
60
61static struct jz4740_mmc_platform_data n516_mmc_pdata = {
62    .gpio_card_detect = GPIO_SD_CD_N,
63    .card_detect_active_low = 1,
64    .gpio_read_only = -1,
65    .gpio_power = GPIO_SD_VCC_EN_N,
66    .power_active_low = 1,
67};
68
69static struct gpio_led n516_leds[] = {
70    {
71        .name = "n516:blue:power",
72        .gpio = GPIO_LED_ENABLE,
73        .default_state = LEDS_GPIO_DEFSTATE_ON,
74        .default_trigger = "nand-disk",
75    }
76};
77
78static struct gpio_led_platform_data n516_leds_pdata = {
79    .leds = n516_leds,
80    .num_leds = ARRAY_SIZE(n516_leds),
81};
82
83static struct platform_device n516_leds_device = {
84    .name = "leds-gpio",
85    .id = -1,
86    .dev = {
87        .platform_data = &n516_leds_pdata,
88    },
89};
90
91static struct mtd_partition n516_partitions[] = {
92    { .name = "NAND BOOT partition",
93      .offset = 0 * 0x100000,
94      .size = 4 * 0x100000,
95    },
96    { .name = "NAND KERNEL partition",
97      .offset = 4 * 0x100000,
98      .size = 4 * 0x100000,
99     },
100    { .name = "NAND ROOTFS partition",
101      .offset = 8 * 0x100000,
102      .size = 504 * 0x100000,
103     },
104};
105
106static struct nand_ecclayout n516_ecclayout = {
107/* .eccbytes = 36,
108    .eccpos = {
109         6, 7, 8, 9, 10, 11, 12, 13, 14,
110        15, 16, 17, 18, 19, 20, 21, 22, 23,
111        24, 25, 26, 27, 28, 29, 30, 31, 32,
112        33, 34, 35, 36, 37, 38, 39, 40, 41,
113    },*/
114    .oobfree = {
115        {
116            .offset = 2,
117            .length = 4
118        },
119        {
120            .offset = 42,
121            .length = 22,
122        }
123    }
124};
125
126static struct jz_nand_platform_data n516_nand_pdata = {
127    .ecc_layout = &n516_ecclayout,
128    .partitions = n516_partitions,
129    .num_partitions = ARRAY_SIZE(n516_partitions),
130    .busy_gpio = 94,
131};
132
133static char *n516_batteries[] = {
134    "n516_battery",
135};
136
137static struct gpio_charger_platform_data n516_charger_pdata = {
138    .name = "usb",
139    .type = POWER_SUPPLY_TYPE_USB,
140    .gpio = GPIO_USB_DETECT,
141    .gpio_active_low = 1,
142    .batteries = n516_batteries,
143    .num_batteries = ARRAY_SIZE(n516_batteries),
144};
145
146static struct platform_device n516_charger_device = {
147    .name = "gpio-charger",
148    .dev = {
149        .platform_data = &n516_charger_pdata,
150    },
151};
152
153static struct platform_device *n516_devices[] __initdata = {
154    &jz4740_nand_device,
155    &n516_leds_device,
156    &jz4740_mmc_device,
157    &jz4740_i2s_device,
158    &jz4740_codec_device,
159    &jz4740_rtc_device,
160    &jz4740_udc_device,
161    &jz4740_i2c_device,
162    &n516_charger_device,
163};
164
165struct jz4740_clock_board_data jz4740_clock_bdata = {
166    .ext_rate = 12000000,
167    .rtc_rate = 32768,
168};
169
170static int n516_setup_platform(void)
171{
172    jz4740_serial_device_register();
173    board_gpio_setup();
174
175    panic_blink = n516_panic_blink;
176    i2c_register_board_info(0, n516_i2c_board_info, ARRAY_SIZE(n516_i2c_board_info));
177    jz4740_mmc_device.dev.platform_data = &n516_mmc_pdata;
178    jz4740_nand_device.dev.platform_data = &n516_nand_pdata;
179
180    return platform_add_devices(n516_devices, ARRAY_SIZE(n516_devices));
181}
182arch_initcall(n516_setup_platform);
183

Archive Download this file



interactive