12 #include <linux/kernel.h>
15 #include <linux/pci.h>
20 #include <linux/i2c.h>
47 #define TSP2_NOR_BOOT_BASE 0xf4000000
48 #define TSP2_NOR_BOOT_SIZE SZ_256K
58 static struct resource tsp2_nor_flash_resource = {
65 .name =
"physmap-flash",
68 .platform_data = &tsp2_nor_flash_data,
71 .resource = &tsp2_nor_flash_resource,
77 #define TSP2_PCI_SLOT0_OFFS 7
78 #define TSP2_PCI_SLOT0_IRQ_PIN 11
93 "to set_irq_type pin %d\n", pin);
98 "gpio_request %d\n", pin);
127 .map_irq = tsp2_pci_map_irq,
130 static int __init tsp2_pci_init(
void)
132 if (machine_is_terastation_pro2())
152 #define TSP2_RTC_GPIO 9
163 #define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2))
165 static int tsp2_miconread(
unsigned char *
buf,
int count)
170 for (i = 0; i <
count; i++) {
188 static int tsp2_miconwrite(
const unsigned char *
buf,
int count)
201 static int tsp2_miconsend(
const unsigned char *
data,
int count)
206 unsigned char send_buf[40];
207 unsigned char correct_ack[3];
211 for (i = 0; i <
count; i++)
216 tsp2_miconwrite(data, count);
219 tsp2_miconwrite(&checksum, 1);
221 if (tsp2_miconread(recv_buf,
sizeof(recv_buf)) <= 3) {
225 memset(&send_buf, 0xff,
sizeof(send_buf));
226 tsp2_miconwrite(send_buf,
sizeof(send_buf));
230 tsp2_miconread(recv_buf,
sizeof(recv_buf));
233 correct_ack[0] = 0x01;
234 correct_ack[1] = data[1];
235 correct_ack[2] = 0x00;
238 if ((recv_buf[0] + recv_buf[1] + recv_buf[2] +
239 recv_buf[3]) & 0xFF) {
241 "Received data[%02x, %02x, %02x, %02x]"
242 "\n", __func__, recv_buf[0],
243 recv_buf[1], recv_buf[2], recv_buf[3]);
246 if (correct_ack[0] == recv_buf[0] &&
247 correct_ack[1] == recv_buf[1] &&
248 correct_ack[2] == recv_buf[2]) {
258 "Received\n", __func__);
268 static void tsp2_power_off(
void)
270 const unsigned char watchdogkill[] = {0x01, 0x35, 0x00};
271 const unsigned char shutdownwait[] = {0x00, 0x0c};
272 const unsigned char poweroff[] = {0x00, 0x06};
276 pr_info(
"%s: triggering power-off...\n", __func__);
288 tsp2_miconsend(watchdogkill,
sizeof(watchdogkill)) ;
289 tsp2_miconsend(shutdownwait,
sizeof(shutdownwait)) ;
290 tsp2_miconsend(poweroff,
sizeof(poweroff));
296 static unsigned int tsp2_mpp_modes[] __initdata = {
320 static void __init tsp2_init(
void)
349 if (tsp2_i2c_rtc.
irq == 0)
350 pr_warning(
"tsp2_init: failed to get RTC IRQ\n");
357 MACHINE_START(TERASTATION_PRO2,
"Buffalo Terastation Pro II/Live")
359 .atag_offset = 0x100,
360 .init_machine = tsp2_init,