USB: serial: option: reimplement interface masking
[linux/fpc-iii.git] / arch / arm / mach-ks8695 / board-acs5k.c
blob937eb1d47e7bb793a774e06c015347e726abc513
1 /*
2 * arch/arm/mach-ks8695/board-acs5k.c
4 * Brivo Systems LLC, ACS-5000 Master Board
6 * Copyright 2008 Simtec Electronics
7 * Daniel Silverstone <dsilvers@simtec.co.uk>
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 as
11 * published by the Free Software Foundation.
13 #include <linux/gpio.h>
14 #include <linux/kernel.h>
15 #include <linux/types.h>
16 #include <linux/interrupt.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/gpio/machine.h>
20 #include <linux/i2c.h>
21 #include <linux/i2c-algo-bit.h>
22 #include <linux/i2c-gpio.h>
23 #include <linux/platform_data/pca953x.h>
25 #include <linux/mtd/mtd.h>
26 #include <linux/mtd/map.h>
27 #include <linux/mtd/physmap.h>
28 #include <linux/mtd/partitions.h>
30 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach/irq.h>
36 #include "devices.h"
37 #include <mach/gpio-ks8695.h>
39 #include "generic.h"
41 static struct gpiod_lookup_table acs5k_i2c_gpiod_table = {
42 .dev_id = "i2c-gpio",
43 .table = {
44 GPIO_LOOKUP_IDX("KS8695", 4, NULL, 0,
45 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
46 GPIO_LOOKUP_IDX("KS8695", 5, NULL, 1,
47 GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
51 static struct i2c_gpio_platform_data acs5k_i2c_device_platdata = {
52 .udelay = 10,
55 static struct platform_device acs5k_i2c_device = {
56 .name = "i2c-gpio",
57 .id = -1,
58 .num_resources = 0,
59 .resource = NULL,
60 .dev = {
61 .platform_data = &acs5k_i2c_device_platdata,
65 static int acs5k_pca9555_setup(struct i2c_client *client,
66 unsigned gpio_base, unsigned ngpio,
67 void *context)
69 static int acs5k_gpio_value[] = {
70 -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, -1, 0, 1, 0, -1, -1
72 int n;
74 for (n = 0; n < ARRAY_SIZE(acs5k_gpio_value); ++n) {
75 gpio_request(gpio_base + n, "ACS-5000 GPIO Expander");
76 if (acs5k_gpio_value[n] < 0)
77 gpio_direction_input(gpio_base + n);
78 else
79 gpio_direction_output(gpio_base + n,
80 acs5k_gpio_value[n]);
81 gpio_export(gpio_base + n, 0); /* Export, direction locked down */
84 return 0;
87 static struct pca953x_platform_data acs5k_i2c_pca9555_platdata = {
88 .gpio_base = 16, /* Start directly after the CPU's GPIO */
89 .invert = 0, /* Do not invert */
90 .setup = acs5k_pca9555_setup,
93 static struct i2c_board_info acs5k_i2c_devs[] __initdata = {
95 I2C_BOARD_INFO("pcf8563", 0x51),
98 I2C_BOARD_INFO("pca9555", 0x20),
99 .platform_data = &acs5k_i2c_pca9555_platdata,
103 static void acs5k_i2c_init(void)
105 /* The gpio interface */
106 gpiod_add_lookup_table(&acs5k_i2c_gpiod_table);
107 platform_device_register(&acs5k_i2c_device);
108 /* I2C devices */
109 i2c_register_board_info(0, acs5k_i2c_devs,
110 ARRAY_SIZE(acs5k_i2c_devs));
113 static struct mtd_partition acs5k_nor_partitions[] = {
114 [0] = {
115 .name = "Boot Agent and config",
116 .size = SZ_256K,
117 .offset = 0,
118 .mask_flags = MTD_WRITEABLE,
120 [1] = {
121 .name = "Kernel",
122 .size = SZ_1M,
123 .offset = SZ_256K,
125 [2] = {
126 .name = "SquashFS1",
127 .size = SZ_2M,
128 .offset = SZ_256K + SZ_1M,
130 [3] = {
131 .name = "SquashFS2",
132 .size = SZ_4M + SZ_2M,
133 .offset = SZ_256K + SZ_1M + SZ_2M,
135 [4] = {
136 .name = "Data",
137 .size = SZ_16M + SZ_4M + SZ_2M + SZ_512K, /* 22.5 MB */
138 .offset = SZ_256K + SZ_8M + SZ_1M,
142 static struct physmap_flash_data acs5k_nor_pdata = {
143 .width = 4,
144 .nr_parts = ARRAY_SIZE(acs5k_nor_partitions),
145 .parts = acs5k_nor_partitions,
148 static struct resource acs5k_nor_resource[] = {
149 [0] = {
150 .start = SZ_32M, /* We expect the bootloader to map
151 * the flash here.
153 .end = SZ_32M + SZ_16M - 1,
154 .flags = IORESOURCE_MEM,
156 [1] = {
157 .start = SZ_32M + SZ_16M,
158 .end = SZ_32M + SZ_32M - SZ_256K - 1,
159 .flags = IORESOURCE_MEM,
163 static struct platform_device acs5k_device_nor = {
164 .name = "physmap-flash",
165 .id = -1,
166 .num_resources = ARRAY_SIZE(acs5k_nor_resource),
167 .resource = acs5k_nor_resource,
168 .dev = {
169 .platform_data = &acs5k_nor_pdata,
173 static void __init acs5k_register_nor(void)
175 int ret;
177 if (acs5k_nor_partitions[0].mask_flags == 0)
178 printk(KERN_WARNING "Warning: Unprotecting bootloader and configuration partition\n");
180 ret = platform_device_register(&acs5k_device_nor);
181 if (ret < 0)
182 printk(KERN_ERR "failed to register physmap-flash device\n");
185 static int __init acs5k_protection_setup(char *s)
187 /* We can't allocate anything here but we should be able
188 * to trivially parse s and decide if we can protect the
189 * bootloader partition or not
191 if (strcmp(s, "no") == 0)
192 acs5k_nor_partitions[0].mask_flags = 0;
194 return 1;
197 __setup("protect_bootloader=", acs5k_protection_setup);
199 static void __init acs5k_init_gpio(void)
201 int i;
203 ks8695_register_gpios();
204 for (i = 0; i < 4; ++i)
205 gpio_request(i, "ACS5K IRQ");
206 gpio_request(7, "ACS5K KS_FRDY");
207 for (i = 8; i < 16; ++i)
208 gpio_request(i, "ACS5K Unused");
210 gpio_request(3, "ACS5K CAN Control");
211 gpio_request(6, "ACS5K Heartbeat");
212 gpio_direction_output(3, 1); /* Default CAN_RESET high */
213 gpio_direction_output(6, 0); /* Default KS8695_ACTIVE low */
214 gpio_export(3, 0); /* export CAN_RESET as output only */
215 gpio_export(6, 0); /* export KS8695_ACTIVE as output only */
218 static void __init acs5k_init(void)
220 acs5k_init_gpio();
222 /* Network device */
223 ks8695_add_device_lan(); /* eth0 = LAN */
224 ks8695_add_device_wan(); /* ethX = WAN */
226 /* NOR devices */
227 acs5k_register_nor();
229 /* I2C bus */
230 acs5k_i2c_init();
233 MACHINE_START(ACS5K, "Brivo Systems LLC ACS-5000 Master board")
234 /* Maintainer: Simtec Electronics. */
235 .atag_offset = 0x100,
236 .map_io = ks8695_map_io,
237 .init_irq = ks8695_init_irq,
238 .init_machine = acs5k_init,
239 .init_time = ks8695_timer_init,
240 .restart = ks8695_restart,
241 MACHINE_END