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/platform_data/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>
37 #include <mach/gpio-ks8695.h>
41 static struct gpiod_lookup_table acs5k_i2c_gpiod_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 = {
55 static struct platform_device acs5k_i2c_device = {
61 .platform_data = &acs5k_i2c_device_platdata,
65 static int acs5k_pca9555_setup(struct i2c_client *client,
66 unsigned gpio_base, unsigned ngpio,
69 static int acs5k_gpio_value[] = {
70 -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, -1, 0, 1, 0, -1, -1
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);
79 gpio_direction_output(gpio_base + n,
81 gpio_export(gpio_base + n, 0); /* Export, direction locked down */
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 __init acs5k_i2c_init(void)
105 /* The gpio interface */
106 gpiod_add_lookup_table(&acs5k_i2c_gpiod_table);
107 platform_device_register(&acs5k_i2c_device);
109 i2c_register_board_info(0, acs5k_i2c_devs,
110 ARRAY_SIZE(acs5k_i2c_devs));
113 static struct mtd_partition acs5k_nor_partitions[] = {
115 .name = "Boot Agent and config",
118 .mask_flags = MTD_WRITEABLE,
128 .offset = SZ_256K + SZ_1M,
132 .size = SZ_4M + SZ_2M,
133 .offset = SZ_256K + SZ_1M + SZ_2M,
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 = {
144 .nr_parts = ARRAY_SIZE(acs5k_nor_partitions),
145 .parts = acs5k_nor_partitions,
148 static struct resource acs5k_nor_resource[] = {
150 .start = SZ_32M, /* We expect the bootloader to map
153 .end = SZ_32M + SZ_16M - 1,
154 .flags = IORESOURCE_MEM,
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",
166 .num_resources = ARRAY_SIZE(acs5k_nor_resource),
167 .resource = acs5k_nor_resource,
169 .platform_data = &acs5k_nor_pdata,
173 static void __init acs5k_register_nor(void)
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);
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;
197 __setup("protect_bootloader=", acs5k_protection_setup);
199 static void __init acs5k_init_gpio(void)
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)
223 ks8695_add_device_lan(); /* eth0 = LAN */
224 ks8695_add_device_wan(); /* ethX = WAN */
227 acs5k_register_nor();
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,