Daniel Silverstone | b74788d | 2009-01-29 11:33:10 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ks8695/board-acs5k.c |
| 3 | * |
| 4 | * Brivo Systems LLC, ACS-5000 Master Board |
| 5 | * |
| 6 | * Copyright 2008 Simtec Electronics |
| 7 | * Daniel Silverstone <dsilvers@simtec.co.uk> |
| 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 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 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 | |
| 20 | #include <linux/i2c.h> |
| 21 | #include <linux/i2c-algo-bit.h> |
| 22 | #include <linux/i2c-gpio.h> |
| 23 | #include <linux/i2c/pca953x.h> |
| 24 | |
| 25 | #include <linux/mtd/mtd.h> |
| 26 | #include <linux/mtd/map.h> |
| 27 | #include <linux/mtd/physmap.h> |
| 28 | #include <linux/mtd/partitions.h> |
| 29 | |
| 30 | #include <asm/mach-types.h> |
| 31 | |
| 32 | #include <asm/mach/arch.h> |
| 33 | #include <asm/mach/map.h> |
| 34 | #include <asm/mach/irq.h> |
| 35 | |
| 36 | #include <mach/devices.h> |
| 37 | #include <mach/gpio.h> |
| 38 | |
| 39 | #include "generic.h" |
| 40 | |
| 41 | static struct i2c_gpio_platform_data acs5k_i2c_device_platdata = { |
| 42 | .sda_pin = 4, |
| 43 | .scl_pin = 5, |
| 44 | .udelay = 10, |
| 45 | }; |
| 46 | |
| 47 | static struct platform_device acs5k_i2c_device = { |
| 48 | .name = "i2c-gpio", |
| 49 | .id = -1, |
| 50 | .num_resources = 0, |
| 51 | .resource = NULL, |
| 52 | .dev = { |
| 53 | .platform_data = &acs5k_i2c_device_platdata, |
| 54 | }, |
| 55 | }; |
| 56 | |
| 57 | static int acs5k_pca9555_setup(struct i2c_client *client, |
| 58 | unsigned gpio_base, unsigned ngpio, |
| 59 | void *context) |
| 60 | { |
| 61 | static int acs5k_gpio_value[] = { |
| 62 | -1, -1, -1, -1, -1, -1, -1, 0, 1, 1, -1, 0, 1, 0, -1, -1 |
| 63 | }; |
| 64 | int n; |
| 65 | |
| 66 | for (n = 0; n < ARRAY_SIZE(acs5k_gpio_value); ++n) { |
| 67 | gpio_request(gpio_base + n, "ACS-5000 GPIO Expander"); |
| 68 | if (acs5k_gpio_value[n] < 0) |
| 69 | gpio_direction_input(gpio_base + n); |
| 70 | else |
| 71 | gpio_direction_output(gpio_base + n, |
| 72 | acs5k_gpio_value[n]); |
| 73 | gpio_export(gpio_base + n, 0); /* Export, direction locked down */ |
| 74 | } |
| 75 | |
| 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | static struct pca953x_platform_data acs5k_i2c_pca9555_platdata = { |
| 80 | .gpio_base = 16, /* Start directly after the CPU's GPIO */ |
| 81 | .invert = 0, /* Do not invert */ |
| 82 | .setup = acs5k_pca9555_setup, |
| 83 | }; |
| 84 | |
| 85 | static struct i2c_board_info acs5k_i2c_devs[] __initdata = { |
| 86 | { |
| 87 | I2C_BOARD_INFO("pcf8563", 0x51), |
| 88 | }, |
| 89 | { |
| 90 | I2C_BOARD_INFO("pca9555", 0x20), |
| 91 | .platform_data = &acs5k_i2c_pca9555_platdata, |
| 92 | }, |
| 93 | }; |
| 94 | |
| 95 | static void __devinit acs5k_i2c_init(void) |
| 96 | { |
| 97 | /* The gpio interface */ |
| 98 | platform_device_register(&acs5k_i2c_device); |
| 99 | /* I2C devices */ |
| 100 | i2c_register_board_info(0, acs5k_i2c_devs, |
| 101 | ARRAY_SIZE(acs5k_i2c_devs)); |
| 102 | } |
| 103 | |
| 104 | static struct mtd_partition acs5k_nor_partitions[] = { |
| 105 | [0] = { |
| 106 | .name = "Boot Agent and config", |
| 107 | .size = SZ_256K, |
| 108 | .offset = 0, |
| 109 | .mask_flags = MTD_WRITEABLE, |
| 110 | }, |
| 111 | [1] = { |
| 112 | .name = "Kernel", |
| 113 | .size = SZ_1M, |
| 114 | .offset = SZ_256K, |
| 115 | }, |
| 116 | [2] = { |
| 117 | .name = "SquashFS1", |
| 118 | .size = SZ_2M, |
| 119 | .offset = SZ_256K + SZ_1M, |
| 120 | }, |
| 121 | [3] = { |
| 122 | .name = "SquashFS2", |
| 123 | .size = SZ_4M + SZ_2M, |
| 124 | .offset = SZ_256K + SZ_1M + SZ_2M, |
| 125 | }, |
| 126 | [4] = { |
| 127 | .name = "Data", |
| 128 | .size = SZ_16M + SZ_4M + SZ_2M + SZ_512K, /* 22.5 MB */ |
| 129 | .offset = SZ_256K + SZ_8M + SZ_1M, |
| 130 | } |
| 131 | }; |
| 132 | |
| 133 | static struct physmap_flash_data acs5k_nor_pdata = { |
| 134 | .width = 4, |
| 135 | .nr_parts = ARRAY_SIZE(acs5k_nor_partitions), |
| 136 | .parts = acs5k_nor_partitions, |
| 137 | }; |
| 138 | |
| 139 | static struct resource acs5k_nor_resource[] = { |
| 140 | [0] = { |
| 141 | .start = SZ_32M, /* We expect the bootloader to map |
| 142 | * the flash here. |
| 143 | */ |
| 144 | .end = SZ_32M + SZ_16M - 1, |
| 145 | .flags = IORESOURCE_MEM, |
| 146 | }, |
| 147 | [1] = { |
| 148 | .start = SZ_32M + SZ_16M, |
| 149 | .end = SZ_32M + SZ_32M - SZ_256K - 1, |
| 150 | .flags = IORESOURCE_MEM, |
| 151 | } |
| 152 | }; |
| 153 | |
| 154 | static struct platform_device acs5k_device_nor = { |
| 155 | .name = "physmap-flash", |
| 156 | .id = -1, |
| 157 | .num_resources = ARRAY_SIZE(acs5k_nor_resource), |
| 158 | .resource = acs5k_nor_resource, |
| 159 | .dev = { |
| 160 | .platform_data = &acs5k_nor_pdata, |
| 161 | }, |
| 162 | }; |
| 163 | |
| 164 | static void __init acs5k_register_nor(void) |
| 165 | { |
| 166 | int ret; |
| 167 | |
| 168 | if (acs5k_nor_partitions[0].mask_flags == 0) |
| 169 | printk(KERN_WARNING "Warning: Unprotecting bootloader and configuration partition\n"); |
| 170 | |
| 171 | ret = platform_device_register(&acs5k_device_nor); |
| 172 | if (ret < 0) |
| 173 | printk(KERN_ERR "failed to register physmap-flash device\n"); |
| 174 | } |
| 175 | |
| 176 | static int __init acs5k_protection_setup(char *s) |
| 177 | { |
| 178 | /* We can't allocate anything here but we should be able |
| 179 | * to trivially parse s and decide if we can protect the |
| 180 | * bootloader partition or not |
| 181 | */ |
| 182 | if (strcmp(s, "no") == 0) |
| 183 | acs5k_nor_partitions[0].mask_flags = 0; |
| 184 | |
| 185 | return 1; |
| 186 | } |
| 187 | |
| 188 | __setup("protect_bootloader=", acs5k_protection_setup); |
| 189 | |
| 190 | static void __init acs5k_init_gpio(void) |
| 191 | { |
| 192 | int i; |
| 193 | |
| 194 | ks8695_register_gpios(); |
| 195 | for (i = 0; i < 4; ++i) |
| 196 | gpio_request(i, "ACS5K IRQ"); |
| 197 | gpio_request(7, "ACS5K KS_FRDY"); |
| 198 | for (i = 8; i < 16; ++i) |
| 199 | gpio_request(i, "ACS5K Unused"); |
| 200 | |
| 201 | gpio_request(3, "ACS5K CAN Control"); |
| 202 | gpio_request(6, "ACS5K Heartbeat"); |
| 203 | gpio_direction_output(3, 1); /* Default CAN_RESET high */ |
| 204 | gpio_direction_output(6, 0); /* Default KS8695_ACTIVE low */ |
| 205 | gpio_export(3, 0); /* export CAN_RESET as output only */ |
| 206 | gpio_export(6, 0); /* export KS8695_ACTIVE as output only */ |
| 207 | } |
| 208 | |
| 209 | static void __init acs5k_init(void) |
| 210 | { |
| 211 | acs5k_init_gpio(); |
| 212 | |
| 213 | /* Network device */ |
| 214 | ks8695_add_device_lan(); /* eth0 = LAN */ |
| 215 | ks8695_add_device_wan(); /* ethX = WAN */ |
| 216 | |
| 217 | /* NOR devices */ |
| 218 | acs5k_register_nor(); |
| 219 | |
| 220 | /* I2C bus */ |
| 221 | acs5k_i2c_init(); |
| 222 | } |
| 223 | |
| 224 | MACHINE_START(ACS5K, "Brivo Systems LLC ACS-5000 Master board") |
| 225 | /* Maintainer: Simtec Electronics. */ |
Daniel Silverstone | b74788d | 2009-01-29 11:33:10 +0100 | [diff] [blame] | 226 | .boot_params = KS8695_SDRAM_PA + 0x100, |
| 227 | .map_io = ks8695_map_io, |
| 228 | .init_irq = ks8695_init_irq, |
| 229 | .init_machine = acs5k_init, |
| 230 | .timer = &ks8695_timer, |
| 231 | MACHINE_END |