From 22258fa40e54ceefe75a6c6a793f5c44d8339b9c Mon Sep 17 00:00:00 2001 From: David Gibson Date: Fri, 11 Jan 2008 14:25:34 +1100 Subject: [POWERPC] Enable RTC for Ebony and Walnut (v2) This patch extends the Ebony and Walnut platform code to instantiate the existing ds1742 RTC class driver for the DS1743 RTC/NVRAM chip found on both those boards. The patch uses a helper function to scan the device tree and instantiate the appropriate platform_device based on it, so it should be easy to extend for other boards which have mmio mapped RTC chips. Along with this, the device tree binding for the ds1743 chips is tweaked, based on the existing DS1385 OF binding found at: http://playground.sun.com/1275/proposals/Closed/Remanded/Accepted/346-it.txt Although that document covers the NVRAM portion of the chip, whereas here we're interested in the RTC portion, so it's not entirely clear if that's a good model. This implements only RTC class driver support - that is /dev/rtc0, not /dev/rtc, and the low-level get/set time callbacks remain unimplemented. That means in order to get at the clock you will either need a modified version of hwclock which will look at /dev/rtc0, or you'll need to configure udev to symlink rtc0 to rtc. Signed-off-by: David Gibson Signed-off-by: Josh Boyer --- arch/powerpc/platforms/40x/walnut.c | 1 + arch/powerpc/platforms/44x/Kconfig | 1 + arch/powerpc/platforms/44x/ebony.c | 2 ++ arch/powerpc/platforms/Kconfig | 6 ++++++ 4 files changed, 10 insertions(+) (limited to 'arch/powerpc/platforms') diff --git a/arch/powerpc/platforms/40x/walnut.c b/arch/powerpc/platforms/40x/walnut.c index f115b6dbf5ad..5d9edd917f92 100644 --- a/arch/powerpc/platforms/40x/walnut.c +++ b/arch/powerpc/platforms/40x/walnut.c @@ -36,6 +36,7 @@ static __initdata struct of_device_id walnut_of_bus[] = { static int __init walnut_device_probe(void) { of_platform_bus_probe(NULL, walnut_of_bus, NULL); + of_instantiate_rtc(); return 0; } diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig index d24801305344..c3e4e8c3c467 100644 --- a/arch/powerpc/platforms/44x/Kconfig +++ b/arch/powerpc/platforms/44x/Kconfig @@ -13,6 +13,7 @@ config EBONY default y select 440GP select PCI + select OF_RTC help This option enables support for the IBM PPC440GP evaluation board. diff --git a/arch/powerpc/platforms/44x/ebony.c b/arch/powerpc/platforms/44x/ebony.c index 481a016e1535..1a8d467bff85 100644 --- a/arch/powerpc/platforms/44x/ebony.c +++ b/arch/powerpc/platforms/44x/ebony.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -38,6 +39,7 @@ static __initdata struct of_device_id ebony_of_bus[] = { static int __init ebony_device_probe(void) { of_platform_bus_probe(NULL, ebony_of_bus, NULL); + of_instantiate_rtc(); return 0; } diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig index 2cec34314d2e..4286664741dd 100644 --- a/arch/powerpc/platforms/Kconfig +++ b/arch/powerpc/platforms/Kconfig @@ -321,6 +321,12 @@ config FSL_ULI1575 config CPM bool +config OF_RTC + bool + help + Uses information from the OF or flattened device tree to instatiate + platform devices for direct mapped RTC chips like the DS1742 or DS1743. + source "arch/powerpc/sysdev/bestcomm/Kconfig" endmenu -- cgit v1.2.3 From f9bdedb2c5f2952f33e4f88038e5c48e27144cda Mon Sep 17 00:00:00 2001 From: Sean MacLennan Date: Tue, 22 Jan 2008 04:55:29 +1100 Subject: [POWERPC] 4xx: PIKA Warp base platform Add the base platform support for the PIKA Warp boards. Signed-off-by: Sean MacLennan Signed-off-by: Josh Boyer --- arch/powerpc/Kconfig | 2 +- arch/powerpc/platforms/44x/Kconfig | 14 +++ arch/powerpc/platforms/44x/Makefile | 2 + arch/powerpc/platforms/44x/warp-nand.c | 105 ++++++++++++++++++++++ arch/powerpc/platforms/44x/warp.c | 153 +++++++++++++++++++++++++++++++++ 5 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/platforms/44x/warp-nand.c create mode 100644 arch/powerpc/platforms/44x/warp.c (limited to 'arch/powerpc/platforms') diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 9ae800d81f89..5e1083829d82 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -480,7 +480,7 @@ config MCA config PCI bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \ || PPC_MPC52xx || (EMBEDDED && (PPC_PSERIES || PPC_ISERIES)) \ - || PPC_PS3 + || PPC_PS3 || 44x default y if !40x && !CPM2 && !8xx && !PPC_83xx \ && !PPC_85xx && !PPC_86xx default PCI_PERMEDIA if !4xx && !CPM2 && !8xx diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig index c3e4e8c3c467..c062c4cbbed5 100644 --- a/arch/powerpc/platforms/44x/Kconfig +++ b/arch/powerpc/platforms/44x/Kconfig @@ -54,6 +54,19 @@ config RAINIER help This option enables support for the AMCC PPC440GRX evaluation board. +config WARP + bool "PIKA Warp" + depends on 44x + default n + select 440EP + help + This option enables support for the PIKA Warp(tm) Appliance. The Warp + is a small computer replacement with up to 9 ports of FXO/FXS plus VOIP + stations and trunks. + + See http://www.pikatechnologies.com/ and follow the "PIKA for Computer + Telephony Developers" link for more information. + #config LUAN # bool "Luan" # depends on 44x @@ -76,6 +89,7 @@ config 440EP select PPC_FPU select IBM440EP_ERR42 select IBM_NEW_EMAC_ZMII + select USB_ARCH_HAS_OHCI config 440EPX bool diff --git a/arch/powerpc/platforms/44x/Makefile b/arch/powerpc/platforms/44x/Makefile index a2a0dc13e9e9..0864d4f1cbc2 100644 --- a/arch/powerpc/platforms/44x/Makefile +++ b/arch/powerpc/platforms/44x/Makefile @@ -5,3 +5,5 @@ obj-$(CONFIG_BAMBOO) += bamboo.o obj-$(CONFIG_SEQUOIA) += sequoia.o obj-$(CONFIG_KATMAI) += katmai.o obj-$(CONFIG_RAINIER) += rainier.o +obj-$(CONFIG_WARP) += warp.o +obj-$(CONFIG_WARP) += warp-nand.o diff --git a/arch/powerpc/platforms/44x/warp-nand.c b/arch/powerpc/platforms/44x/warp-nand.c new file mode 100644 index 000000000000..84ab78ff8c03 --- /dev/null +++ b/arch/powerpc/platforms/44x/warp-nand.c @@ -0,0 +1,105 @@ +/* + * PIKA Warp(tm) NAND flash specific routines + * + * Copyright (c) 2008 PIKA Technologies + * Sean MacLennan + */ + +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_MTD_NAND_NDFC + +#define CS_NAND_0 1 /* use chip select 1 for NAND device 0 */ + +#define WARP_NAND_FLASH_REG_ADDR 0xD0000000UL +#define WARP_NAND_FLASH_REG_SIZE 0x2000 + +static struct resource warp_ndfc = { + .start = WARP_NAND_FLASH_REG_ADDR, + .end = WARP_NAND_FLASH_REG_ADDR + WARP_NAND_FLASH_REG_SIZE, + .flags = IORESOURCE_MEM, +}; + +static struct mtd_partition nand_parts[] = { + { + .name = "kernel", + .offset = 0, + .size = 0x0200000 + }, + { + .name = "root", + .offset = 0x0200000, + .size = 0x3400000 + }, + { + .name = "user", + .offset = 0x3600000, + .size = 0x0A00000 + }, +}; + +struct ndfc_controller_settings warp_ndfc_settings = { + .ccr_settings = (NDFC_CCR_BS(CS_NAND_0) | NDFC_CCR_ARAC1), + .ndfc_erpn = 0, +}; + +static struct ndfc_chip_settings warp_chip0_settings = { + .bank_settings = 0x80002222, +}; + +struct platform_nand_ctrl warp_nand_ctrl = { + .priv = &warp_ndfc_settings, +}; + +static struct platform_device warp_ndfc_device = { + .name = "ndfc-nand", + .id = 0, + .dev = { + .platform_data = &warp_nand_ctrl, + }, + .num_resources = 1, + .resource = &warp_ndfc, +}; + +static struct nand_ecclayout nand_oob_16 = { + .eccbytes = 3, + .eccpos = { 0, 1, 2, 3, 6, 7 }, + .oobfree = { {.offset = 8, .length = 16} } +}; + +static struct platform_nand_chip warp_nand_chip0 = { + .nr_chips = 1, + .chip_offset = CS_NAND_0, + .nr_partitions = ARRAY_SIZE(nand_parts), + .partitions = nand_parts, + .chip_delay = 50, + .ecclayout = &nand_oob_16, + .priv = &warp_chip0_settings, +}; + +static struct platform_device warp_nand_device = { + .name = "ndfc-chip", + .id = 0, + .num_resources = 1, + .resource = &warp_ndfc, + .dev = { + .platform_data = &warp_nand_chip0, + .parent = &warp_ndfc_device.dev, + } +}; + +static int warp_setup_nand_flash(void) +{ + platform_device_register(&warp_ndfc_device); + platform_device_register(&warp_nand_device); + + return 0; +} +device_initcall(warp_setup_nand_flash); + +#endif diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c new file mode 100644 index 000000000000..8f01563dbd2a --- /dev/null +++ b/arch/powerpc/platforms/44x/warp.c @@ -0,0 +1,153 @@ +/* + * PIKA Warp(tm) board specific routines + * + * Copyright (c) 2008 PIKA Technologies + * Sean MacLennan + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "44x.h" + + +static __initdata struct of_device_id warp_of_bus[] = { + { .compatible = "ibm,plb4", }, + { .compatible = "ibm,opb", }, + { .compatible = "ibm,ebc", }, + {}, +}; + +static int __init warp_device_probe(void) +{ + of_platform_bus_probe(NULL, warp_of_bus, NULL); + return 0; +} +machine_device_initcall(warp, warp_device_probe); + +static int __init warp_probe(void) +{ + unsigned long root = of_get_flat_dt_root(); + + return of_flat_dt_is_compatible(root, "pika,warp"); +} + +define_machine(warp) { + .name = "Warp", + .probe = warp_probe, + .progress = udbg_progress, + .init_IRQ = uic_init_tree, + .get_irq = uic_get_irq, + .restart = ppc44x_reset_system, + .calibrate_decr = generic_calibrate_decr, +}; + + +#define LED_GREEN (0x80000000 >> 0) +#define LED_RED (0x80000000 >> 1) + + +/* This is for the power LEDs 1 = on, 0 = off, -1 = leave alone */ +void warp_set_power_leds(int green, int red) +{ + static void __iomem *gpio_base = NULL; + unsigned leds; + + if (gpio_base == NULL) { + struct device_node *np; + + /* Power LEDS are on the second GPIO controller */ + np = of_find_compatible_node(NULL, NULL, "ibm,gpio-440EP"); + if (np) + np = of_find_compatible_node(np, NULL, "ibm,gpio-440EP"); + if (np == NULL) { + printk(KERN_ERR __FILE__ ": Unable to find gpio\n"); + return; + } + + gpio_base = of_iomap(np, 0); + of_node_put(np); + if (gpio_base == NULL) { + printk(KERN_ERR __FILE__ ": Unable to map gpio"); + return; + } + } + + leds = in_be32(gpio_base); + + switch (green) { + case 0: leds &= ~LED_GREEN; break; + case 1: leds |= LED_GREEN; break; + } + switch (red) { + case 0: leds &= ~LED_RED; break; + case 1: leds |= LED_RED; break; + } + + out_be32(gpio_base, leds); +} +EXPORT_SYMBOL(warp_set_power_leds); + + +#ifdef CONFIG_SENSORS_AD7414 +static int pika_dtm_thread(void __iomem *fpga) +{ + extern int ad7414_get_temp(int index); + + while (!kthread_should_stop()) { + int temp = ad7414_get_temp(0); + + out_be32(fpga, temp); + + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(HZ); + } + + return 0; +} + +static int __init pika_dtm_start(void) +{ + struct task_struct *dtm_thread; + struct device_node *np; + struct resource res; + void __iomem *fpga; + + np = of_find_compatible_node(NULL, NULL, "pika,fpga"); + if (np == NULL) + return -ENOENT; + + /* We do not call of_iomap here since it would map in the entire + * fpga space, which is over 8k. + */ + if (of_address_to_resource(np, 0, &res)) { + of_node_put(np); + return -ENOENT; + } + of_node_put(np); + + fpga = ioremap(res.start + 0x20, 4); + if (fpga == NULL) + return -ENOENT; + + dtm_thread = kthread_run(pika_dtm_thread, fpga + 0x20, "pika-dtm"); + if (IS_ERR(dtm_thread)) { + iounmap(fpga); + return PTR_ERR(dtm_thread); + } + + return 0; +} +device_initcall(pika_dtm_start); +#endif -- cgit v1.2.3