2 +++ b/arch/mips/lantiq/falcon/Kconfig
8 +config LANTIQ_MACH_EASY98000
16 +++ b/arch/mips/lantiq/falcon/Makefile
18 +obj-y := clk-falcon.o devices.o gpio.o prom.o sysctrl.o reset.o
19 +obj-y += softdog_vpe.o
20 +obj-$(CONFIG_LANTIQ_MACH_EASY98000) += addon-easy98000.o
21 +obj-$(CONFIG_LANTIQ_MACH_EASY98000) += mach-easy98000.o
23 +++ b/arch/mips/lantiq/falcon/clk-falcon.c
26 + * This program is free software; you can redistribute it and/or modify
27 + * it under the terms of the GNU General Public License as published by
28 + * the Free Software Foundation; either version 2 of the License, or
29 + * (at your option) any later version.
31 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
34 +#include <linux/io.h>
35 +#include <linux/module.h>
36 +#include <linux/init.h>
38 +#include <asm/time.h>
40 +#include <asm/div64.h>
42 +#include <lantiq_soc.h>
45 +#include <gpon_reg_base.h>
46 +#include <sys1_reg.h>
48 +static struct gpon_reg_sys1 * const pSYS1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
51 +ltq_get_io_region_clock(void)
53 + return 200000000; /* 200 MHz */
55 +EXPORT_SYMBOL(ltq_get_io_region_clock);
60 + if ((ltq_r32(&pSYS1->cpu0cc) & CPU0CC_CPUDIV) == CPU0CC_CPUDIV_SELFHALF)
61 + return 200000000; /* 200 MHz */
63 + return 400000000; /* 400 MHz */
65 +EXPORT_SYMBOL(ltq_get_cpu_hz);
72 +EXPORT_SYMBOL(ltq_get_fpi_hz);
74 +++ b/arch/mips/lantiq/falcon/devices.c
76 +#include <linux/init.h>
77 +#include <linux/module.h>
78 +#include <linux/types.h>
79 +#include <linux/string.h>
80 +#include <linux/mtd/physmap.h>
81 +#include <linux/kernel.h>
82 +#include <linux/reboot.h>
83 +#include <linux/platform_device.h>
84 +#include <linux/leds.h>
85 +#include <linux/etherdevice.h>
86 +#include <linux/reboot.h>
87 +#include <linux/time.h>
88 +#include <linux/io.h>
89 +#include <linux/gpio.h>
90 +#include <linux/leds.h>
91 +#include <linux/spi/spi.h>
92 +#include <linux/mtd/nand.h>
94 +#include <asm/bootinfo.h>
99 +#include <falcon/falcon_irq.h>
100 +#include <falcon/gpon_reg_base.h>
101 +#include <falcon/ebu_reg.h>
102 +#include <falcon/sys1_reg.h>
103 +#include <falcon/sys_eth_reg.h>
105 +#include <falcon/sysctrl.h>
107 +#include "devices.h"
109 +unsigned char ltq_ethaddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
110 +EXPORT_SYMBOL(ltq_ethaddr);
113 +falcon_set_ethaddr(char *str)
115 + sscanf(str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
116 + <q_ethaddr[0], <q_ethaddr[1], <q_ethaddr[2],
117 + <q_ethaddr[3], <q_ethaddr[4], <q_ethaddr[5]);
120 +__setup("ethaddr=", falcon_set_ethaddr);
123 +static struct resource falcon_asc0_resources[] =
125 + MEM_RES("asc0",GPON_ASC0_BASE,GPON_ASC0_END),
126 + IRQ_RES("tx",INT_NUM_IM3_IRL0),
127 + IRQ_RES("rx",INT_NUM_IM3_IRL0+1),
128 + IRQ_RES("err",INT_NUM_IM3_IRL0+2),
131 +static struct resource falcon_asc1_resources[] =
133 + MEM_RES("asc1",GPON_ASC1_BASE,GPON_ASC1_END),
134 + IRQ_RES("tx",INT_NUM_IM3_IRL0+8),
135 + IRQ_RES("rx",INT_NUM_IM3_IRL0+9),
136 + IRQ_RES("err",INT_NUM_IM3_IRL0+10),
139 +void __init falcon_register_asc(int port)
143 + platform_device_register_simple("ltq_asc", 0,
144 + falcon_asc0_resources, ARRAY_SIZE(falcon_asc0_resources));
147 + platform_device_register_simple("ltq_asc", 1,
148 + falcon_asc1_resources, ARRAY_SIZE(falcon_asc1_resources));
156 +static struct resource ltq_nor_resource =
157 + MEM_RES("nor",LTQ_FLASH_START,LTQ_FLASH_START + LTQ_FLASH_MAX - 1);
159 +static struct platform_device ltq_nor = {
161 + .resource = <q_nor_resource,
162 + .num_resources = 1,
165 +void __init falcon_register_nor(struct physmap_flash_data *data)
167 + ltq_nor.dev.platform_data = data;
168 + platform_device_register(<q_nor);
172 +static struct resource ltq_spi_resources[] = {
173 + MEM_RES("ebu", GPON_EBU_BASE, GPON_EBU_END),
174 + MEM_RES("sys1", GPON_SYS1_BASE, GPON_SYS1_END)
177 +static struct platform_device ltq_spi = {
178 + .name = "falcon_spi",
179 + .resource = ltq_spi_resources,
180 + .num_resources = ARRAY_SIZE(ltq_spi_resources)
183 +void __init falcon_register_spi_flash(struct spi_board_info *data)
185 + spi_register_board_info(data, 1);
186 + platform_device_register(<q_spi);
190 +static struct gpon_reg_ebu __iomem *membase_ebu;
191 +static const char *part_probes[] = { "cmdlinepart", NULL };
193 +static int falcon_nand_ready(struct mtd_info *mtd)
195 + u32 modcon = __raw_readl(&membase_ebu->modcon);
197 + return (((modcon & (MODCON_STS|MODCON_STSEDGE)) ==
198 + (MODCON_STS|MODCON_STSEDGE)));
201 +/* address lines used for NAND control signals */
202 +#define NAND_ADDR_ALE (1<<16)
203 +#define NAND_ADDR_CLE (1<<17)
205 +static void falcon_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
207 + struct nand_chip *this = mtd->priv;
208 + unsigned long nandaddr = (unsigned long) this->IO_ADDR_W;
210 + if (ctrl & NAND_CTRL_CHANGE) {
211 + nandaddr &= ~(NAND_ADDR_ALE | NAND_ADDR_CLE);
213 + if (ctrl & NAND_CLE)
214 + nandaddr |= NAND_ADDR_CLE;
215 + if (ctrl & NAND_ALE)
216 + nandaddr |= NAND_ADDR_ALE;
218 + this->IO_ADDR_W = (void __iomem *) nandaddr;
221 + if (cmd != NAND_CMD_NONE)
222 + writeb(cmd, this->IO_ADDR_W);
225 +static struct platform_nand_data falcon_flash_nand_data = {
229 + .part_probe_types = part_probes,
232 + .cmd_ctrl = falcon_hwcontrol,
233 + .dev_ready = falcon_nand_ready,
237 +static struct resource ltq_nand_resources[] = {
238 + MEM_RES("nand", LTQ_FLASH_START, LTQ_FLASH_START + LTQ_FLASH_MAX - 1),
239 + MEM_RES("ebu", GPON_EBU_BASE, GPON_EBU_END),
242 +static struct platform_device ltq_flash_nand = {
243 + .name = "gen_nand",
245 + .num_resources = ARRAY_SIZE(ltq_nand_resources),
246 + .resource = ltq_nand_resources,
248 + .platform_data = &falcon_flash_nand_data,
252 +void __init falcon_register_nand(void)
254 + membase_ebu = ioremap_nocache(ltq_nand_resources[1].start,
255 + resource_size(<q_nand_resources[1]));
258 + platform_device_register(<q_flash_nand);
262 +static struct resource falcon_wdt_resource =
263 + MEM_RES("watchdog",GPON_WDT_BASE,GPON_WDT_END);
265 +void __init falcon_register_wdt(void)
267 + platform_device_register_simple("ltq_wdt", 0, &falcon_wdt_resource, 1);
271 +#define DECLARE_GPIO_RES(port) \
272 +static struct resource falcon_gpio ## port ## _resources[] = { \
273 + MEM_RES("gpio"#port,GPON_GPIO ## port ## _BASE,GPON_GPIO ## port ## _END), \
274 + MEM_RES("padctrl"#port,GPON_PADCTRL ## port ## _BASE,GPON_PADCTRL ## port ## _END), \
275 + IRQ_RES("gpio_mux"#port,FALCON_IRQ_GPIO_P ## port ) \
277 +DECLARE_GPIO_RES(0);
278 +DECLARE_GPIO_RES(1);
279 +DECLARE_GPIO_RES(2);
280 +#ifdef REGISTER_ALL_GPIO_PORTS
282 +#error NR_IRQS to low for all gpio irqs
284 +DECLARE_GPIO_RES(3);
285 +DECLARE_GPIO_RES(4);
288 +void __init falcon_register_gpio(void)
290 + platform_device_register_simple("falcon_gpio", 0,
291 + falcon_gpio0_resources, ARRAY_SIZE(falcon_gpio0_resources));
292 + platform_device_register_simple("falcon_gpio", 1,
293 + falcon_gpio1_resources, ARRAY_SIZE(falcon_gpio1_resources));
294 + platform_device_register_simple("falcon_gpio", 2,
295 + falcon_gpio2_resources, ARRAY_SIZE(falcon_gpio2_resources));
296 + sys1_hw_activate(ACTS_PADCTRL1 | ACTS_P1);
297 + sys_eth_hw_activate(SYS_ETH_ACTS_PADCTRL0 | SYS_ETH_ACTS_PADCTRL2 |
298 + SYS_ETH_ACTS_P0 | SYS_ETH_ACTS_P2);
300 +#ifdef REGISTER_ALL_GPIO_PORTS
301 + /* optional gpio ports: not registered,
302 + as the pins are EBU specific and always used by linux */
303 + platform_device_register_simple("falcon_gpio", 3,
304 + falcon_gpio3_resources, ARRAY_SIZE(falcon_gpio3_resources));
305 + platform_device_register_simple("falcon_gpio", 4,
306 + falcon_gpio4_resources, ARRAY_SIZE(falcon_gpio4_resources));
307 + sys1_hw_activate(ACTS_PADCTRL3 | ACTS_PADCTRL4 | ACTS_P3 | ACTS_P4);
311 +static struct resource falcon_i2c_resources[] = {
312 + MEM_RES("i2c", GPON_I2C_BASE,GPON_I2C_END),
313 + IRQ_RES("i2c_lb", FALCON_IRQ_I2C_LBREQ),
314 + IRQ_RES("i2c_b", FALCON_IRQ_I2C_BREQ),
315 + IRQ_RES("i2c_err", FALCON_IRQ_I2C_I2C_ERR),
316 + IRQ_RES("i2c_p", FALCON_IRQ_I2C_I2C_P),
319 +void __init falcon_register_i2c(void)
321 + platform_device_register_simple("i2c-falcon", 0,
322 + falcon_i2c_resources, ARRAY_SIZE(falcon_i2c_resources));
323 + sys1_hw_activate(ACTS_I2C_ACT);
326 +void __init falcon_register_crypto(void)
328 + platform_device_register_simple("ltq_falcon_deu", 0, NULL, 0);
331 +++ b/arch/mips/lantiq/falcon/devices.h
333 +#ifndef _FALCON_DEVICES_H__
334 +#define _FALCON_DEVICES_H__
336 +#include <linux/mtd/physmap.h>
337 +#include <linux/spi/spi.h>
338 +#include <linux/spi/flash.h>
340 +extern void __init falcon_register_asc(int port);
341 +extern void __init falcon_register_i2c(void);
342 +extern void __init falcon_register_spi_flash(struct spi_board_info *data);
343 +extern void __init falcon_register_gpio(void);
344 +extern void __init falcon_register_nor(struct physmap_flash_data *data);
345 +extern void __init falcon_register_nand(void);
346 +extern void __init falcon_register_wdt(void);
347 +extern void __init falcon_register_crypto(void);
349 +#define IRQ_RES(resname,irq) {.name=resname,.start=(irq),.flags=IORESOURCE_IRQ}
350 +#define MEM_RES(resname,adr_start,adr_end) \
351 + { .name=resname, .flags=IORESOURCE_MEM, \
352 + .start=((adr_start)&~KSEG1),.end=((adr_end)&~KSEG1) }
356 +++ b/arch/mips/lantiq/falcon/prom.c
359 + * This program is free software; you can redistribute it and/or modify
360 + * it under the terms of the GNU General Public License as published by
361 + * the Free Software Foundation; either version 2 of the License, or
362 + * (at your option) any later version.
364 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
367 +#include <linux/module.h>
368 +#include <linux/clk.h>
369 +#include <asm/bootinfo.h>
370 +#include <asm/time.h>
372 +#include <lantiq_soc.h>
376 +#include <falcon/gpon_reg_base.h>
377 +#include <falcon/status_reg.h>
378 +#include <falcon/sys1_reg.h>
380 +#include "../prom.h"
382 +static struct gpon_reg_status * const pSTATUS = (struct gpon_reg_status *)GPON_STATUS_BASE;
384 +#define SOC_FALCON "Falcon"
393 +ltq_soc_detect(struct ltq_soc_info *i)
395 + i->partnum = (ltq_r32(&pSTATUS->chipid) & STATUS_CHIPID_PARTNR_MASK) >> STATUS_CHIPID_PARTNR_OFFSET;
396 + i->rev = (ltq_r32(&pSTATUS->chipid) & STATUS_CHIPID_VERSION_MASK) >> STATUS_CHIPID_VERSION_OFFSET;
397 + switch (i->partnum)
399 + case SOC_ID_FALCON:
400 + i->name = SOC_FALCON;
401 + i->type = SOC_TYPE_FALCON;
405 + printk(KERN_ERR "unknown partnum : 0x%08X\n", i->partnum);
411 +++ b/arch/mips/lantiq/falcon/sysctrl.c
414 + * This program is free software; you can redistribute it and/or
415 + * modify it under the terms of the GNU General Public License as
416 + * published by the Free Software Foundation; either version 2 of
417 + * the License, or (at your option) any later version.
419 + * This program is distributed in the hope that it will be useful,
420 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
421 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
422 + * GNU General Public License for more details.
424 + * You should have received a copy of the GNU General Public License
425 + * along with this program; if not, write to the Free Software
426 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
427 + * MA 02111-1307 USA
429 + * Copyright (C) 2010 Thomas Langer, Lantiq Deutschland
432 +#include <linux/cpu.h>
433 +#include <linux/init.h>
434 +#include <linux/kernel.h>
435 +#include <linux/pm.h>
436 +#include <linux/io.h>
437 +#include <linux/ioport.h>
438 +#include <linux/clk.h>
439 +#include <asm/reboot.h>
441 +#include <falcon/gpon_reg_base.h>
442 +#include <falcon/status_reg.h>
443 +#include <falcon/sys1_reg.h>
444 +#include <falcon/sys_eth_reg.h>
445 +#include <falcon/sys_gpe_reg.h>
447 +#include <falcon/sysctrl.h>
449 +/* mapping to linux hw-accessor routines */
450 +#define reg_r32(reg) __raw_readl(reg)
451 +#define reg_w32(val, reg) __raw_writel(val, reg)
452 +#define reg_w32_mask(clear, set, reg) reg_w32((reg_r32(reg) & ~(clear)) | (set), reg)
454 +static struct gpon_reg_sys1 * const sys1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
455 +static struct gpon_reg_sys_eth * const sys_eth = (struct gpon_reg_sys_eth *)GPON_SYS_ETH_BASE;
456 +static struct gpon_reg_sys_gpe * const sys_gpe = (struct gpon_reg_sys_gpe *)GPON_SYS_GPE_BASE;
457 +static struct gpon_reg_status * const status = (struct gpon_reg_status *)GPON_STATUS_BASE;
460 + * Activate the selected module(s)
461 + * Enables the clock of the module and activates the module itself.
463 + * \param[in] mask bitmask of module(s), as for registers SYS1.ACT
466 +void sys1_hw_activate(u32 mask)
468 + sys1_w32(mask, clken);
469 + sys1_w32(mask, act);
471 + while ( (sys1_r32(acts) & mask) != mask) {
475 +EXPORT_SYMBOL(sys1_hw_activate);
478 + * Deactivate the selected module(s)
479 + * Disables the clock of the module and deactivates the module itself.
481 + * \param[in] mask bitmask of module(s), as for registers SYS1.DEACT
484 +void sys1_hw_deactivate(u32 mask)
486 + sys1_w32(mask, clkclr);
487 + sys1_w32(mask, deact);
489 + while ( (sys1_r32(acts) & mask) != 0) {
493 +EXPORT_SYMBOL(sys1_hw_deactivate);
496 + * Clock enable for the selected module(s)
497 + * Enables the clock of the module.
499 + * \param[in] mask bitmask of module(s), as for registers SYS1.CLKEN
502 +void sys1_hw_clk_enable(u32 mask)
504 + sys1_w32(mask, clken);
506 + while ( (sys1_r32(clks) & mask) != mask) {
510 +EXPORT_SYMBOL(sys1_hw_clk_enable);
513 + * Clock disable for the selected module(s)
514 + * disables the clock of the module.
516 + * \param[in] mask bitmask of module(s), as for registers SYS1.CLKCLR
519 +void sys1_hw_clk_disable(u32 mask)
521 + sys1_w32(mask, clkclr);
523 + while ( (sys1_r32(clks) & mask) != 0) {
527 +EXPORT_SYMBOL(sys1_hw_clk_disable);
530 + * Reboots the selected module(s)
531 + * Triggers the reboot of the module.
533 + * \param[in] mask bitmask of module(s), as for registers SYS1.RBT
536 +void sys1_hw_activate_or_reboot(u32 mask)
538 + u32 acts = sys1_r32(acts);
539 + /* is not already active? */
540 + if ((~acts & mask) != 0)
541 + sys1_hw_activate(~acts & mask);
542 + sys1_w32(acts & mask, rbt);
543 + while ( (sys1_r32(acts) & mask) != mask) {
547 +EXPORT_SYMBOL(sys1_hw_activate_or_reboot);
550 + * Activate the selected module(s)
551 + * Enables the clock of the module and activates the module itself.
553 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.ACT
556 +void sys_eth_hw_activate(u32 mask)
558 + sys_eth_w32(mask, clken);
559 + sys_eth_w32(mask, act);
561 + while ( (sys_eth_r32(acts) & mask) != mask) {
565 +EXPORT_SYMBOL(sys_eth_hw_activate);
568 + * Deactivate the selected module(s)
569 + * Disables the clock of the module and deactivates the module itself.
571 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.DEACT
574 +void sys_eth_hw_deactivate(u32 mask)
576 + sys_eth_w32(mask, clkclr);
577 + sys_eth_w32(mask, deact);
579 + while ( (sys_eth_r32(acts) & mask) != 0) {
583 +EXPORT_SYMBOL(sys_eth_hw_deactivate);
586 + * Clock enable for the selected module(s)
587 + * Enables the clock of the module.
589 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.CLKEN
592 +void sys_eth_hw_clk_enable(u32 mask)
594 + sys_eth_w32(mask, clken);
596 + while ( (sys_eth_r32(clks) & mask) != mask) {
600 +EXPORT_SYMBOL(sys_eth_hw_clk_enable);
603 + * Clock disable for the selected module(s)
604 + * disables the clock of the module.
606 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.CLKCLR
609 +void sys_eth_hw_clk_disable(u32 mask)
611 + sys_eth_w32(mask, clkclr);
613 + while ( (sys_eth_r32(clks) & mask) != 0) {
617 +EXPORT_SYMBOL(sys_eth_hw_clk_disable);
620 + * Reboots the selected module(s)
621 + * Triggers the reboot of the module.
623 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.RBT
626 +void sys_eth_hw_activate_or_reboot(u32 mask)
628 + u32 acts = sys_eth_r32(acts);
629 + /* is not already active? */
630 + if ((~acts & mask) != 0)
631 + sys_eth_hw_activate(~acts & mask);
632 + sys_eth_w32(acts & mask, rbt);
633 + while ( (sys_eth_r32(acts) & mask) != mask) {
637 +EXPORT_SYMBOL(sys_eth_hw_activate_or_reboot);
639 +static int gpe_clk_is_enabled(void)
643 + rd_data = sys1_r32(infrac);
644 + if (rd_data & (1<<(INFRAC_GP_OFFSET+1)))
649 +static void enable_gpe_clk(void)
653 + u32 rd_data_to_keep;
656 + if (gpe_clk_is_enabled())
657 + /* clock already active, no need to change here */
660 + if (status_r32(config) == 0)
661 + aeFreq = 1; /* use 625MHz on unfused chip */
663 + aeFreq = (status_r32(config) & STATUS_CONFIG_GPEFREQ_MASK) >> STATUS_CONFIG_GPEFREQ_OFFSET;
664 + rd_data = sys1_r32(infrac);
665 + /* clear gpe-fsel and enable bits */
666 + rd_data_to_keep = rd_data & ~(7<<(INFRAC_GP_OFFSET+1));
669 + sys1_w32(rd_data_to_keep | (aeFreq<<(INFRAC_GP_OFFSET+2)), infrac);
671 + for (i = 0; i <10; i++) /* wait 10 cycles */
674 + /* keep new fsel and enable */
675 + sys1_w32(rd_data_to_keep | (aeFreq<<(INFRAC_GP_OFFSET+2)) |
676 + (1<<(INFRAC_GP_OFFSET+1)), infrac);
677 + for (i = 0; i <100; i++) /* wait 100 cycles */
682 + * Activate the selected module(s)
683 + * Enables the clock of the module and activates the module itself.
685 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.ACT
688 +void sys_gpe_hw_activate(u32 mask)
691 + sys_gpe_w32(mask, clken);
692 + sys_gpe_w32(mask, act);
694 + while ( (sys_gpe_r32(acts) & mask) != mask) {
698 +EXPORT_SYMBOL(sys_gpe_hw_activate);
701 + * Deactivate the selected module(s)
702 + * Disables the clock of the module and deactivates the module itself.
704 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.DEACT
707 +void sys_gpe_hw_deactivate(u32 mask)
710 + sys_gpe_w32(mask, clkclr);
711 + sys_gpe_w32(mask, deact);
713 + while ( (sys_gpe_r32(acts) & mask) != 0) {
717 +EXPORT_SYMBOL(sys_gpe_hw_deactivate);
720 + * Clock enable for the selected module(s)
721 + * Enables the clock of the module.
723 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.CLKEN
726 +void sys_gpe_hw_clk_enable(u32 mask)
729 + sys_gpe_w32(mask, clken);
731 + while ( (sys_gpe_r32(clks) & mask) != mask) {
735 +EXPORT_SYMBOL(sys_gpe_hw_clk_enable);
738 + * Clock disable for the selected module(s)
739 + * disables the clock of the module.
741 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.CLKCLR
744 +void sys_gpe_hw_clk_disable(u32 mask)
747 + sys_gpe_w32(mask, clkclr);
749 + while ( (sys_gpe_r32(clks) & mask) != 0) {
753 +EXPORT_SYMBOL(sys_gpe_hw_clk_disable);
756 + * Reboots the selected module(s)
757 + * Triggers the reboot of the module.
759 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.RBT
762 +void sys_gpe_hw_activate_or_reboot(u32 mask)
766 + acts = sys_gpe_r32(acts);
767 + /* is not already active? */
768 + if ((~acts & mask) != 0)
769 + sys_gpe_hw_activate(~acts & mask);
770 + sys_gpe_w32(acts & mask, rbt);
771 + while ( (sys_gpe_r32(acts) & mask) != mask) {
775 +EXPORT_SYMBOL(sys_gpe_hw_activate_or_reboot);
778 + * Retrieve activation status of the selected hardware module(s)
780 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.RBT
781 + * \return int 1 - if hardware module(s) is activated (including clock)
783 + int sys_gpe_hw_is_activated(u32 mask)
785 + if (gpe_clk_is_enabled() == 0)
788 + if ((sys_gpe_r32(clks) & mask) != mask)
791 + return ((sys_gpe_r32(acts) & mask) == mask);
793 +EXPORT_SYMBOL(sys_gpe_hw_is_activated);
795 +++ b/arch/mips/lantiq/falcon/gpio.c
798 + * This program is free software; you can redistribute it and/or modify
799 + * it under the terms of the GNU General Public License as published by
800 + * the Free Software Foundation; either version 2 of the License, or
801 + * (at your option) any later version.
803 + * This program is distributed in the hope that it will be useful,
804 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
805 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
806 + * GNU General Public License for more details.
808 + * You should have received a copy of the GNU General Public License
809 + * along with this program; if not, write to the Free Software
810 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
812 + * Copyright (C) 2010 Thomas Langer, Lantiq Deutschland
818 + - provide mask of available pins per platform_data
821 +#include <linux/module.h>
822 +#include <linux/types.h>
823 +#include <linux/errno.h>
824 +#include <linux/init.h>
825 +#include <linux/seq_file.h>
826 +#include <linux/platform_device.h>
827 +#include <linux/uaccess.h>
828 +#include <linux/gpio.h>
829 +#include <linux/irq.h>
830 +#include <linux/interrupt.h>
831 +#include <linux/slab.h>
834 +#include <falcon/falcon_irq.h>
836 +#include <linux/version.h>
837 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
838 +#define for_each_set_bit for_each_bit
841 +#define gpio_r32(reg) __raw_readl(reg)
842 +#define gpio_w32(val, reg) __raw_writel(val, reg)
843 +#define gpio_w32_mask(clear, set, reg) gpio_w32((gpio_r32(reg) & ~(clear)) | (set), reg)
846 +/** register structure for padctrl
847 + (mainly needed for mux control) */
848 +typedef struct gpon_padctrl_s
850 + /** Multiplexer Control Register
851 + The value 0 (the reset-value) is always the default function corresponding to the pad's name. The value 1 selects always the GPIO functionality (if available). */
852 + unsigned int muxc[32];
853 + /** Pull Up Enable Register */
854 + unsigned int puen; /* 0x00000080 */
855 + /** Pull Down Enable Register */
856 + unsigned int pden; /* 0x00000084 */
857 + /** Slew Rate Control Register */
858 + unsigned int src; /* 0x00000088 */
859 + /** Drive Current Control Register */
860 + unsigned int dcc; /* 0x0000008C */
862 + unsigned int res_0[24]; /* 0x00000090 */
863 + /** Pad Control Availability Register */
864 + unsigned int avail; /* 0x000000F0 */
867 +/** register structure for gpio port */
868 +typedef struct gpon_gpio_s
870 + /** Data Output Register
871 + Via this register the output values of the different bits can be set if they are switched as outputs. */
872 + unsigned int out; /* 0x00000000 */
873 + /** Data Input Register
874 + Via this register the input values of the different bits can be observed. */
875 + unsigned int in; /* 0x00000004 */
876 + /** Direction Register
877 + Via this register the input direction of the different bits can be determined. */
878 + unsigned int dir; /* 0x00000008 */
880 + unsigned int res_0[3]; /* 0x0000000C */
881 + /** External Interrupt Control Register 0 */
882 + unsigned int exintcr0; /* 0x00000018 */
883 + /** External Interrupt Control Register 1 */
884 + unsigned int exintcr1; /* 0x0000001C */
885 + /** IRN Capture Register
886 + This register shows the currently active interrupt events masked with the corresponding enable bits of the IRNEN register. The interrupts can be acknowledged by a write operation. */
887 + unsigned int irncr; /* 0x00000020 */
888 + /** IRN Interrupt Control Register
889 + A write operation directly effects the interrupts. This can be used to trigger events under software control for testing purposes. A read operation returns the unmasked interrupt events. */
890 + unsigned int irnicr; /* 0x00000024 */
891 + /** IRN Interrupt Enable Register
892 + This register contains the enable (or mask) bits for the interrupts. Disabled interrupts are not visible in the IRNCR register and are not signalled via the interrupt line towards the controller. */
893 + unsigned int irnen; /* 0x00000028 */
894 + /** IRN Interrupt Configuration Register
895 + Configures the interrupts bitwise to be edge-senstivie or level-sensitive. */
896 + unsigned int irncfg; /* 0x0000002C */
897 + /** IRN Interrupt Enable Set Register
898 + The corresponding bit in the IRNEN register can be set with an atomic access. */
899 + unsigned int irnenset; /* 0x00000030 */
900 + /** IRN Interrupt Enable Clear Register
901 + The corresponding bit in the IRNEN register can be cleared with an atomic access. */
902 + unsigned int irnenclr; /* 0x00000034 */
904 + unsigned int res_1[2]; /* 0x00000038 */
905 + /** Output Set Register
906 + This register can be used to set certain bits within the OUT register without touching the other bits. */
907 + unsigned int outset; /* 0x00000040 */
908 + /** Output Clear Register
909 + This register can be used to clear certain bits within the OUT register without touching the other bits. */
910 + unsigned int outclr; /* 0x00000044 */
911 + /** Direction Set Register
912 + This register can be used to set certain bits within the DIR register without touching the other bits. */
913 + unsigned int dirset; /* 0x00000048 */
914 + /** Direction Clear Register
915 + This register can be used to clear certain bits within the DIR register without touching the other bits. */
916 + unsigned int dirclr; /* 0x0000004C */
919 +struct falcon_gpio_port {
920 + struct gpio_chip gpio_chip;
921 + gpon_padctrl0_t __iomem *pad;
922 + gpon_gpio_t __iomem *port;
923 + struct resource *pad_req; /* resources requested */
924 + struct resource *port_req;
925 + unsigned int irq_base;
926 + unsigned int chained_irq;
929 +static int gpio_exported = 0;
930 +static int __init gpio_export_setup(char *str)
932 + get_option(&str, &gpio_exported);
935 +__setup("gpio_exported=", gpio_export_setup);
937 +static inline struct falcon_gpio_port *to_falcon_gpio_port(struct gpio_chip *chip)
939 + return container_of(chip, struct falcon_gpio_port, gpio_chip);
942 +static int falcon_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
944 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
945 + gpio_w32(1<<offset, &gpio_port->port->dirclr);
949 +static int falcon_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, int value)
951 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
952 + gpio_w32(1<<offset, &gpio_port->port->dirset);
956 +static void falcon_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
958 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
960 + gpio_w32(1<<offset, &gpio_port->port->outset);
962 + gpio_w32(1<<offset, &gpio_port->port->outclr);
965 +static int falcon_gpio_get(struct gpio_chip *chip, unsigned int offset)
967 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
968 + if ((gpio_r32(&gpio_port->port->dir) >> offset) & 1)
969 + return (gpio_r32(&gpio_port->port->out) >> offset) & 1;
971 + return (gpio_r32(&gpio_port->port->in) >> offset) & 1;
974 +static int falcon_gpio_request(struct gpio_chip *chip, unsigned offset)
976 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
977 + if ( (gpio_r32(&gpio_port->pad->avail) >> offset) & 1) {
978 + if (gpio_r32(&gpio_port->pad->muxc[offset]) > 1)
980 + /* switch on gpio function */
981 + gpio_w32(1, &gpio_port->pad->muxc[offset]);
988 +static void falcon_gpio_free(struct gpio_chip *chip, unsigned offset)
990 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
991 + if ( (gpio_r32(&gpio_port->pad->avail) >> offset) & 1) {
992 + if (gpio_r32(&gpio_port->pad->muxc[offset]) > 1)
994 + /* switch off gpio function */
995 + gpio_w32(0, &gpio_port->pad->muxc[offset]);
999 +static int falcon_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
1001 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
1002 + /* no checks: this functions is only registered with valid irq_base */
1003 + return gpio_port->irq_base + offset;
1006 +static void falcon_gpio_disable_irq(struct irq_data *d)
1008 + struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
1009 + unsigned int offset = d->irq-gpio_port->irq_base;
1010 + gpio_w32(1<<offset, &gpio_port->port->irnenclr);
1013 +static void falcon_gpio_enable_irq(struct irq_data *d)
1015 + struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
1016 + unsigned int offset = d->irq-gpio_port->irq_base;
1018 + if (gpio_r32(&gpio_port->pad->muxc[offset]) < 1) {
1019 + /* switch on gpio function */
1020 + gpio_w32(1, &gpio_port->pad->muxc[offset]);
1023 + gpio_w32(1<<offset, &gpio_port->port->irnenset);
1026 +static void falcon_gpio_ack_irq(struct irq_data *d)
1028 + struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
1029 + unsigned int offset = d->irq-gpio_port->irq_base;
1030 + gpio_w32(1<<offset, &gpio_port->port->irncr);
1033 +static void falcon_gpio_mask_and_ack_irq(struct irq_data *d)
1035 + struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
1036 + unsigned int offset = d->irq-gpio_port->irq_base;
1037 + gpio_w32(1<<offset, &gpio_port->port->irnenclr);
1038 + gpio_w32(1<<offset, &gpio_port->port->irncr);
1041 +static struct irq_chip falcon_gpio_irq_chip;
1042 +static int falcon_gpio_irq_type(struct irq_data *d, unsigned int type)
1044 + struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
1045 + unsigned int offset = d->irq-gpio_port->irq_base;
1046 + unsigned int mask = 1 << offset;
1048 + if ((type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_NONE)
1051 + if ((type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) != 0) {
1052 + /* level triggered */
1053 + gpio_w32_mask(0, mask, &gpio_port->port->irncfg);
1054 + irq_set_chip_and_handler_name(d->irq,
1055 + &falcon_gpio_irq_chip, handle_level_irq, "mux");
1057 + /* edge triggered */
1058 + gpio_w32_mask(mask, 0, &gpio_port->port->irncfg);
1059 + irq_set_chip_and_handler_name(d->irq,
1060 + &falcon_gpio_irq_chip, handle_simple_irq, "mux");
1063 + if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
1064 + gpio_w32_mask(mask, 0, &gpio_port->port->exintcr0);
1065 + gpio_w32_mask(0, mask, &gpio_port->port->exintcr1);
1067 + if ((type & (IRQ_TYPE_EDGE_RISING |IRQ_TYPE_LEVEL_HIGH)) != 0) {
1068 + /* positive logic: rising edge, high level */
1069 + gpio_w32_mask(mask, 0, &gpio_port->port->exintcr0);
1071 + /* negative logic: falling edge, low level */
1072 + gpio_w32_mask(0, mask, &gpio_port->port->exintcr0);
1074 + gpio_w32_mask(mask, 0, &gpio_port->port->exintcr1);
1077 + return gpio_direction_input(gpio_port->gpio_chip.base + offset);
1080 +static void falcon_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
1082 + struct falcon_gpio_port *gpio_port = irq_desc_get_handler_data(desc);
1083 + unsigned long irncr;
1086 + irncr = gpio_r32(&gpio_port->port->irncr);
1087 + /* acknowledge interrupt */
1088 + gpio_w32(irncr, &gpio_port->port->irncr);
1090 + desc->irq_data.chip->irq_ack(&desc->irq_data);
1092 + for_each_set_bit(offset, &irncr, gpio_port->gpio_chip.ngpio)
1093 + generic_handle_irq(gpio_port->irq_base + offset);
1096 +static struct irq_chip falcon_gpio_irq_chip = {
1097 + .name = "gpio_irq_mux",
1098 + .irq_mask = falcon_gpio_disable_irq,
1099 + .irq_unmask = falcon_gpio_enable_irq,
1100 + .irq_ack = falcon_gpio_ack_irq,
1101 + .irq_mask_ack = falcon_gpio_mask_and_ack_irq,
1102 + .irq_set_type = falcon_gpio_irq_type,
1105 +static struct irqaction gpio_cascade = {
1106 + .handler = no_action,
1107 + .flags = IRQF_DISABLED,
1108 + .name = "gpio_cascade",
1111 +static int falcon_gpio_probe(struct platform_device *pdev)
1113 + struct falcon_gpio_port *gpio_port;
1115 + struct resource *gpiores, *padres;
1118 + gpiores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1119 + padres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1120 + irq = platform_get_irq(pdev, 0);
1121 + if (!gpiores || !padres)
1124 + gpio_port = kzalloc(sizeof(*gpio_port), GFP_KERNEL);
1125 + if (gpio_port == NULL)
1128 + gpio_port->gpio_chip.label = "falcon-gpio";
1129 + gpio_port->gpio_chip.direction_input = falcon_gpio_direction_input;
1130 + gpio_port->gpio_chip.direction_output = falcon_gpio_direction_output;
1131 + gpio_port->gpio_chip.get = falcon_gpio_get;
1132 + gpio_port->gpio_chip.set = falcon_gpio_set;
1133 + gpio_port->gpio_chip.request = falcon_gpio_request;
1134 + gpio_port->gpio_chip.free = falcon_gpio_free;
1135 + gpio_port->gpio_chip.base = 100 * pdev->id;
1136 + gpio_port->gpio_chip.ngpio = 32;
1137 + gpio_port->gpio_chip.dev = &pdev->dev;
1138 + gpio_port->gpio_chip.exported = gpio_exported;
1140 + gpio_port->port_req = request_mem_region(gpiores->start,
1141 + resource_size(gpiores), pdev->name);
1142 + gpio_port->pad_req = request_mem_region(padres->start,
1143 + resource_size(padres), pdev->name);
1144 + if (!gpio_port->port_req || !gpio_port->pad_req) {
1145 + dev_err(&pdev->dev, "cannot claim register area\n");
1150 + gpio_port->port = ioremap_nocache(gpiores->start,
1151 + resource_size(gpiores));
1152 + gpio_port->pad = ioremap_nocache(padres->start,
1153 + resource_size(padres));
1154 + if (!gpio_port->port || !gpio_port->pad) {
1155 + dev_err(&pdev->dev, "Could not map io ranges\n");
1162 + * irq_chip support
1164 + gpio_port->gpio_chip.to_irq = falcon_gpio_to_irq;
1165 + gpio_port->irq_base = INT_NUM_EXTRA_START + 32 * pdev->id;
1167 + for (i = 0; i < 32; i++) {
1168 + irq_set_chip_and_handler_name(gpio_port->irq_base + i,
1169 + &falcon_gpio_irq_chip, handle_simple_irq, "mux");
1170 + irq_set_chip_data(gpio_port->irq_base + i, gpio_port);
1171 + /* FIXME: set default cfg to level triggered */
1172 + //gpio_w32_mask(0, 1<<i, &gpio_port->port->irncfg);
1173 + /* set to negative logic (falling edge, low level) */
1174 + gpio_w32_mask(0, 1<<i, &gpio_port->port->exintcr0);
1177 + gpio_port->chained_irq = irq;
1178 + setup_irq(irq, &gpio_cascade);
1179 + irq_set_handler_data(irq, gpio_port);
1180 + irq_set_chained_handler(irq, falcon_gpio_irq_handler);
1183 + ret = gpiochip_add(&gpio_port->gpio_chip);
1185 + dev_err(&pdev->dev, "Could not register gpiochip %d, %d\n",
1189 + platform_set_drvdata(pdev, gpio_port);
1193 + dev_err(&pdev->dev, "Error in gpio_probe %d, %d\n", pdev->id, ret);
1194 + if (gpio_port->port_req)
1195 + release_resource(gpio_port->port_req);
1196 + if (gpio_port->pad_req)
1197 + release_resource(gpio_port->pad_req);
1199 + if (gpio_port->port)
1200 + iounmap(gpio_port->port);
1201 + if (gpio_port->pad)
1202 + iounmap(gpio_port->pad);
1207 +static int falcon_gpio_remove(struct platform_device *pdev)
1209 + struct falcon_gpio_port *gpio_port = platform_get_drvdata(pdev);
1212 + ret = gpiochip_remove(&gpio_port->gpio_chip);
1213 + if (gpio_port->port_req)
1214 + release_resource(gpio_port->port_req);
1215 + if (gpio_port->pad_req)
1216 + release_resource(gpio_port->pad_req);
1217 + if (gpio_port->port)
1218 + iounmap(gpio_port->port);
1219 + if (gpio_port->pad)
1220 + iounmap(gpio_port->pad);
1227 +static struct platform_driver falcon_gpio_driver = {
1228 + .probe = falcon_gpio_probe,
1229 + .remove = __devexit_p(falcon_gpio_remove),
1231 + .name = "falcon_gpio",
1232 + .owner = THIS_MODULE,
1236 +int __init falcon_gpio_init(void)
1240 + printk(KERN_INFO "FALC(tm) ON GPIO Driver, (C) 2011 Lantiq Deutschland Gmbh\n");
1241 + ret = platform_driver_register(&falcon_gpio_driver);
1243 + pr_err( "falcon_gpio: Error registering platform driver!");
1247 +void __exit falcon_gpio_exit(void)
1249 + platform_driver_unregister(&falcon_gpio_driver);
1252 +int gpio_to_irq(unsigned int gpio)
1254 + return __gpio_to_irq(gpio);
1256 +EXPORT_SYMBOL(gpio_to_irq);
1258 +module_init(falcon_gpio_init);
1259 +module_exit(falcon_gpio_exit);
1261 +++ b/arch/mips/include/asm/mach-lantiq/falcon/falcon.h
1264 + * This program is free software; you can redistribute it and/or modify
1265 + * it under the terms of the GNU General Public License as published by
1266 + * the Free Software Foundation; either version 2 of the License, or
1267 + * (at your option) any later version.
1269 + * Copyright (C) 2005 infineon
1270 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
1273 +#ifdef CONFIG_SOC_FALCON
1275 +#include <lantiq_soc.h>
1276 +#include <falcon/gpon_reg_base.h>
1280 +++ b/arch/mips/lantiq/falcon/reset.c
1283 + * This program is free software; you can redistribute it and/or modify
1284 + * it under the terms of the GNU General Public License as published by
1285 + * the Free Software Foundation; either version 2 of the License, or
1286 + * (at your option) any later version.
1288 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
1291 +#include <linux/init.h>
1292 +#include <linux/io.h>
1293 +#include <linux/pm.h>
1294 +#include <asm/reboot.h>
1295 +#include <linux/module.h>
1297 +#include <falcon.h>
1298 +#include <falcon/gpon_reg_base.h>
1299 +#include <falcon/status_reg.h>
1300 +#include <falcon/sys1_reg.h>
1302 +static struct gpon_reg_sys1 * const pSYS1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
1304 +#define WDT_PW1 0x00BE0000
1305 +#define WDT_PW2 0x00DC0000
1306 +#define WDT_REG_BASE (KSEG1 | 0x1F8803F0)
1308 +/* This function is used by the watchdog driver */
1309 +int ltq_reset_cause(void)
1313 +EXPORT_SYMBOL_GPL(ltq_reset_cause);
1316 +ltq_machine_restart(char *command)
1318 + printk(KERN_NOTICE "System restart\n");
1319 + local_irq_disable();
1320 + ltq_w32(0, (void*)0xBF200000); /* reset Bootreg RVEC */
1322 + ltq_w32(RBT_CPU_TRIG, &pSYS1->rbt);
1324 + /* use workaround via watchdog timer */
1325 + ltq_w32(WDT_PW1, (void*)WDT_REG_BASE);
1327 + (0x3 << 26) | /* PWL */
1328 + (0x2 << 24) | /* CLKDIV */
1329 + (0x1 << 31) | /* enable */
1331 + (void*)WDT_REG_BASE);
1337 +ltq_machine_halt(void)
1339 + printk(KERN_NOTICE "System halted.\n");
1340 + local_irq_disable();
1345 +ltq_machine_power_off(void)
1347 + printk(KERN_NOTICE "Please turn off the power now.\n");
1348 + local_irq_disable();
1353 +mips_reboot_setup(void)
1355 + _machine_restart = ltq_machine_restart;
1356 + _machine_halt = ltq_machine_halt;
1357 + pm_power_off = ltq_machine_power_off;
1361 +arch_initcall(mips_reboot_setup);
1363 +++ b/arch/mips/lantiq/falcon/mach-easy98000.c
1365 +#include <linux/init.h>
1366 +#include <linux/platform_device.h>
1367 +#include <linux/leds.h>
1368 +#include <linux/gpio.h>
1369 +#include <linux/gpio_buttons.h>
1370 +#include <linux/etherdevice.h>
1371 +#include <linux/mtd/mtd.h>
1372 +#include <linux/mtd/partitions.h>
1373 +#include <linux/mtd/physmap.h>
1374 +#include <linux/input.h>
1375 +#include <linux/interrupt.h>
1376 +#include <linux/dm9000.h>
1377 +#include <linux/i2c.h>
1378 +#include <linux/i2c-gpio.h>
1379 +#include <linux/spi/spi.h>
1380 +#include <linux/spi/spi_gpio.h>
1381 +#include <linux/spi/eeprom.h>
1383 +#include "../machtypes.h"
1385 +#include "devices.h"
1386 +#include "dev-leds-gpio.h"
1388 +#define EASY98000_GPIO_LED_0 9
1389 +#define EASY98000_GPIO_LED_1 10
1390 +#define EASY98000_GPIO_LED_2 11
1391 +#define EASY98000_GPIO_LED_3 12
1392 +#define EASY98000_GPIO_LED_4 13
1393 +#define EASY98000_GPIO_LED_5 14
1395 +extern unsigned char ltq_ethaddr[6];
1397 +static struct mtd_partition easy98000_nor_partitions[] =
1405 + .name = "uboot_env",
1406 + .offset = 0x40000,
1407 + .size = 0x40000, /* 2 sectors for redundant env. */
1411 + .offset = 0x80000,
1412 + .size = 0xF80000, /* map only 16 MiB */
1416 +static struct physmap_flash_data easy98000_nor_flash_data = {
1417 + .nr_parts = ARRAY_SIZE(easy98000_nor_partitions),
1418 + .parts = easy98000_nor_partitions,
1421 +static struct flash_platform_data easy98000_spi_flash_platform_data = {
1423 + .parts = easy98000_nor_partitions,
1424 + .nr_parts = ARRAY_SIZE(easy98000_nor_partitions)
1427 +static struct spi_board_info easy98000_spi_flash_data __initdata = {
1428 + .modalias = "m25p80",
1431 + .max_speed_hz = 10 * 1000 * 1000,
1432 + .mode = SPI_MODE_3,
1433 + .platform_data = &easy98000_spi_flash_platform_data
1436 +static struct gpio_led easy98000_leds_gpio[] __initdata = {
1438 + .name = "easy98000:green:0",
1439 + .gpio = EASY98000_GPIO_LED_0,
1442 + .name = "easy98000:green:1",
1443 + .gpio = EASY98000_GPIO_LED_1,
1446 + .name = "easy98000:green:2",
1447 + .gpio = EASY98000_GPIO_LED_2,
1450 + .name = "easy98000:green:3",
1451 + .gpio = EASY98000_GPIO_LED_3,
1454 + .name = "easy98000:green:4",
1455 + .gpio = EASY98000_GPIO_LED_4,
1458 + .name = "easy98000:green:5",
1459 + .gpio = EASY98000_GPIO_LED_5,
1464 +#define CONFIG_DM9000_BASE 0x14000000
1465 +#define DM9000_IO (CONFIG_DM9000_BASE + 3)
1466 +#define DM9000_DATA (CONFIG_DM9000_BASE + 1)
1468 +static struct dm9000_plat_data dm9000_plat_data = {
1469 + .flags = DM9000_PLATF_8BITONLY,
1470 + //.dev_addr = { }, /* possibility to provide an ethernet address for the chip */
1473 +static struct resource dm9000_resources[] = {
1474 + MEM_RES("dm9000_io", DM9000_IO, DM9000_IO),
1475 + MEM_RES("dm9000_data", DM9000_DATA, DM9000_DATA),
1477 + /* with irq (210 -> gpio 110) the driver is very unreliable */
1478 + .start = -1, /* use polling */
1480 + .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
1484 +static struct platform_device dm9000_platform = {
1487 + .num_resources = ARRAY_SIZE(dm9000_resources),
1488 + .resource = dm9000_resources,
1490 + .platform_data = (void *) &dm9000_plat_data,
1494 +extern int easy98000_addon_has_dm9000(void);
1495 +static void __init register_davicom(void)
1497 + if (!easy98000_addon_has_dm9000())
1500 + if (!is_valid_ether_addr(ltq_ethaddr))
1501 + random_ether_addr(dm9000_plat_data.dev_addr);
1503 + memcpy(dm9000_plat_data.dev_addr, ltq_ethaddr, 6);
1504 + /* change to "Locally Administered Address" */
1505 + dm9000_plat_data.dev_addr[0] |= 0x2;
1507 + platform_device_register(&dm9000_platform);
1510 +static struct i2c_gpio_platform_data easy98000_i2c_gpio_data = {
1515 +static struct platform_device easy98000_i2c_gpio_device = {
1516 + .name = "i2c-gpio",
1519 + .platform_data = &easy98000_i2c_gpio_data,
1523 +void __init register_easy98000_cpld(void)
1525 + platform_device_register_simple("easy98000_cpld_led", 0, NULL, 0);
1526 + platform_device_register_simple("easy98000_addon", 0, NULL, 0);
1529 +/* setup gpio based spi bus/device for access to the eeprom on the board */
1530 +#define SPI_GPIO_MRST 102
1531 +#define SPI_GPIO_MTSR 103
1532 +#define SPI_GPIO_CLK 104
1533 +#define SPI_GPIO_CS0 105
1534 +#define SPI_GPIO_CS1 106
1535 +#define SPI_GPIO_BUS_NUM 1
1537 +static struct spi_gpio_platform_data easy98000_spi_gpio_data = {
1538 + .sck = SPI_GPIO_CLK,
1539 + .mosi = SPI_GPIO_MTSR,
1540 + .miso = SPI_GPIO_MRST,
1541 + .num_chipselect = 2,
1544 +static struct platform_device easy98000_spi_gpio_device = {
1545 + .name = "spi_gpio",
1546 + .id = SPI_GPIO_BUS_NUM,
1547 + .dev.platform_data = &easy98000_spi_gpio_data,
1550 +static struct spi_eeprom at25160n = {
1551 + .byte_len = 16 * 1024 / 8,
1552 + .name = "at25160n",
1554 + .flags = EE_ADDR2,
1557 +static struct spi_board_info easy98000_spi_gpio_devices __initdata = {
1558 + .modalias = "at25",
1559 + .bus_num = SPI_GPIO_BUS_NUM,
1560 + .max_speed_hz = 1000 * 1000,
1561 + .mode = SPI_MODE_3,
1563 + .controller_data = (void *) SPI_GPIO_CS1,
1564 + .platform_data = &at25160n,
1567 +static void __init easy98000_spi_gpio_init(void)
1569 + spi_register_board_info(&easy98000_spi_gpio_devices, 1);
1570 + platform_device_register(&easy98000_spi_gpio_device);
1573 +static void __init easy98000_init_common(void)
1575 + falcon_register_asc(0);
1576 + falcon_register_gpio();
1577 + falcon_register_wdt();
1578 + falcon_register_i2c();
1579 + platform_device_register(&easy98000_i2c_gpio_device);
1580 + register_davicom();
1581 + ltq_add_device_leds_gpio(-1, ARRAY_SIZE(easy98000_leds_gpio),
1582 + easy98000_leds_gpio);
1583 + register_easy98000_cpld();
1584 + falcon_register_crypto();
1585 + easy98000_spi_gpio_init();
1588 +static void __init easy98000_init(void)
1590 + easy98000_init_common();
1591 + falcon_register_nor(&easy98000_nor_flash_data);
1594 +static void __init easy98000sf_init(void)
1596 + easy98000_init_common();
1597 + falcon_register_spi_flash(&easy98000_spi_flash_data);
1600 +static void __init easy98000nand_init(void)
1602 + easy98000_init_common();
1603 + falcon_register_nand();
1606 +MIPS_MACHINE(LANTIQ_MACH_EASY98000,
1608 + "EASY98000 Eval Board",
1611 +MIPS_MACHINE(LANTIQ_MACH_EASY98000SF,
1613 + "EASY98000 Eval Board (Serial Flash)",
1614 + easy98000sf_init);
1616 +MIPS_MACHINE(LANTIQ_MACH_EASY98000NAND,
1618 + "EASY98000 Eval Board (NAND Flash)",
1619 + easy98000nand_init);
1621 +++ b/arch/mips/lantiq/falcon/softdog_vpe.c
1624 +** =============================================================================
1625 +** FILE NAME : softdog_vpe.c
1627 +** DATE : 24-03-2008
1628 +** AUTHOR : LXDB Team
1629 +** DESCRIPTION : This header file contains the code for the watchdog
1630 +** implentation on vpe1 side.
1632 +** COPYRIGHT : Copyright (c) 2008
1633 +** Am Campeon 1-12, 85579 Neubiberg, Germany
1634 +** Any use of this software is subject to the conclusion of a respective
1635 +** License agreement. Without such a License agreement no rights to the
1636 +** software are granted
1639 +** $Date $Author $Comment
1640 +** 24-03-2008 LXDB Initial version
1641 +** ============================================================================
1644 +#include <linux/module.h>
1645 +#include <linux/moduleparam.h>
1646 +#include <linux/types.h>
1647 +#include <linux/timer.h>
1648 +#include <linux/reboot.h>
1649 +#include <linux/init.h>
1650 +#include <linux/jiffies.h>
1652 +#include <falcon/vpe.h>
1654 +static unsigned long last_wdog_value;
1655 +static unsigned long vpe1_wdog_cleared;
1657 +static unsigned long vpe1_wdog_dead;
1658 +static void watchdog_vpe0_fire(unsigned long); /* Called when vpe0 timer expires */
1659 +static void keep_alive_vpe0(unsigned long);
1660 +VPE_SW_WDOG_RESET reset_local_fn;
1663 +static struct timer_list watchdog_vpe0_ticktock =
1664 + TIMER_INITIALIZER(watchdog_vpe0_fire, 0, 0);
1666 +static void watchdog_vpe0_fire (unsigned long flags)
1668 + volatile unsigned long *wdog_ctr_value;
1669 + wdog_ctr_value = (void*)vpe1_wdog_ctr;
1670 + if (*wdog_ctr_value == last_wdog_value) { /* VPE1 watchdog expiry handling */
1671 + vpe1_sw_wdog_stop(flags);
1673 + printk(KERN_DEBUG "VPE1 watchdog reset handler called\n");
1674 + /* Call the reset handler function */
1675 + reset_local_fn(flags);
1676 + } else { /* Everything is OK on vpe1 side. Continue. */
1677 + last_wdog_value = *wdog_ctr_value;
1678 + vpe1_wdog_cleared++;
1679 + keep_alive_vpe0(flags);
1683 +int32_t vpe1_sw_wdog_register_reset_handler (VPE_SW_WDOG_RESET reset_fn)
1685 + reset_local_fn = (VPE_SW_WDOG_RESET)reset_fn;
1689 +static void keep_alive_vpe0(unsigned long flags)
1691 + mod_timer(&watchdog_vpe0_ticktock, jiffies+ vpe1_wdog_timeout );
1694 +unsigned long vpe1_sw_wdog_start(unsigned long flags)
1696 + volatile unsigned long *wdog_ctr_value;
1697 + wdog_ctr_value = (void*)vpe1_wdog_ctr;
1698 + *wdog_ctr_value = 0;
1699 + last_wdog_value = 0;
1700 + keep_alive_vpe0(flags);
1704 +unsigned long vpe1_sw_wdog_stop(unsigned long flags)
1706 + del_timer(&watchdog_vpe0_ticktock);
1710 +static int __init watchdog_vpe1_init(void)
1712 + /* Nothing to be done here */
1716 +static void __exit watchdog_vpe1_exit(void)
1718 + unsigned long flags=0;
1719 + vpe1_sw_wdog_stop(flags);
1722 +module_init(watchdog_vpe1_init);
1723 +module_exit(watchdog_vpe1_exit);
1725 +EXPORT_SYMBOL(vpe1_sw_wdog_register_reset_handler);
1726 +EXPORT_SYMBOL(vpe1_sw_wdog_start);
1727 +EXPORT_SYMBOL(vpe1_sw_wdog_stop);
1729 +MODULE_AUTHOR("LXDB");
1730 +MODULE_DESCRIPTION("Software Watchdog For VPE1");
1731 +MODULE_LICENSE("GPL");
1733 +++ b/arch/mips/include/asm/mach-lantiq/falcon/vpe.h
1736 + * This program is free software; you can redistribute it and/or modify
1737 + * it under the terms of the GNU General Public License as published by
1738 + * the Free Software Foundation; either version 2 of the License, or
1739 + * (at your option) any later version.
1741 + * This program is distributed in the hope that it will be useful,
1742 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1743 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1744 + * GNU General Public License for more details.
1746 + * You should have received a copy of the GNU General Public License
1747 + * along with this program; if not, write to the Free Software
1748 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
1750 + * Copyright (C) 2005 infineon
1751 + * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
1754 +#ifndef _IFXMIPS_VPE_H__
1755 +#define _IFXMIPS_VPE_H__
1757 +/* For the explanation of the APIs please refer the section "MT APRP Kernel
1758 + * Programming" in AR9 SW Architecture Specification
1760 +int32_t vpe1_sw_start(void* sw_start_addr, uint32_t tcmask, uint32_t flags);
1761 +int32_t vpe1_sw_stop(uint32_t flags);
1762 +uint32_t vpe1_get_load_addr (uint32_t flags);
1763 +uint32_t vpe1_get_max_mem (uint32_t flags);
1765 +int32_t vpe1_set_boot_param(char *field, char *value, char flags);
1766 +int32_t vpe1_get_boot_param(char *field, char **value, char flags);
1768 +/* Watchdog APIs */
1769 +extern unsigned long vpe1_wdog_ctr;
1770 +extern unsigned long vpe1_wdog_timeout;
1772 +unsigned long vpe1_sw_wdog_start(unsigned long);
1773 +unsigned long vpe1_sw_wdog_stop(unsigned long);
1775 +typedef int (*VPE_SW_WDOG_RESET)(unsigned long wdog_cleared_ok_count);
1776 +int32_t vpe1_sw_wdog_register_reset_handler(VPE_SW_WDOG_RESET reset_fn);
1779 --- a/arch/mips/lantiq/Kconfig
1780 +++ b/arch/mips/lantiq/Kconfig
1783 select SOC_TYPE_XWAY
1790 source "arch/mips/lantiq/xway/Kconfig"
1791 +source "arch/mips/lantiq/falcon/Kconfig"
1794 --- a/arch/mips/lantiq/Makefile
1795 +++ b/arch/mips/lantiq/Makefile
1797 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
1799 obj-$(CONFIG_SOC_TYPE_XWAY) += xway/
1800 +obj-$(CONFIG_SOC_FALCON) += falcon/
1801 --- a/arch/mips/lantiq/Platform
1802 +++ b/arch/mips/lantiq/Platform
1804 cflags-$(CONFIG_LANTIQ) += -I$(srctree)/arch/mips/include/asm/mach-lantiq
1805 load-$(CONFIG_LANTIQ) = 0xffffffff80002000
1806 cflags-$(CONFIG_SOC_TYPE_XWAY) += -I$(srctree)/arch/mips/include/asm/mach-lantiq/xway
1807 +cflags-$(CONFIG_SOC_FALCON) += -I$(srctree)/arch/mips/include/asm/mach-lantiq/falcon
1808 --- a/arch/mips/lantiq/machtypes.h
1809 +++ b/arch/mips/lantiq/machtypes.h
1811 LTQ_MACH_GENERIC = 0,
1812 LTQ_MACH_EASY50712, /* Danube evaluation board */
1813 LTQ_MACH_EASY50601, /* Amazon SE evaluation board */
1816 + LANTIQ_MACH_EASY98000, /* Falcon Eval Board, NOR Flash */
1817 + LANTIQ_MACH_EASY98000SF, /* Falcon Eval Board, Serial Flash */
1818 + LANTIQ_MACH_EASY98000NAND, /* Falcon Eval Board, NAND Flash */
1819 + LANTIQ_MACH_EASY98020, /* Falcon Reference Board */
1824 +++ b/arch/mips/lantiq/falcon/addon-easy98000.c
1827 + * EASY98000 CPLD Addon driver
1829 + * Copyright (C) 2011 Thomas Langer <thomas.langer@lantiq.com>
1831 + * This program is free software; you can redistribute it and/or modify it
1832 + * under the terms of the GNU General Public License version 2 as published
1833 + * by the Free Software Foundation.
1837 +#include <linux/kernel.h>
1838 +#include <linux/version.h>
1839 +#include <linux/types.h>
1840 +#include <linux/init.h>
1841 +#include <linux/platform_device.h>
1842 +#include <linux/errno.h>
1843 +#include <linux/slab.h>
1844 +#include <linux/proc_fs.h>
1845 +#include <linux/seq_file.h>
1847 +struct easy98000_reg_cpld {
1848 + u16 cmdreg1; /* 0x1 */
1849 + u16 cmdreg0; /* 0x0 */
1850 + u16 idreg0; /* 0x3 */
1851 + u16 resreg; /* 0x2 */
1852 + u16 intreg; /* 0x5 */
1853 + u16 idreg1; /* 0x4 */
1854 + u16 ledreg; /* 0x7 */
1855 + u16 pcmconconfig; /* 0x6 */
1856 + u16 res0; /* 0x9 */
1857 + u16 ethledreg; /* 0x8 */
1858 + u16 res1[4]; /* 0xa-0xd */
1859 + u16 cpld1v; /* 0xf */
1860 + u16 cpld2v; /* 0xe */
1862 +static struct easy98000_reg_cpld * const cpld =
1863 + (struct easy98000_reg_cpld *)(KSEG1 | 0x17c00000);
1864 +#define cpld_r8(reg) (__raw_readw(&cpld->reg) & 0xFF)
1865 +#define cpld_w8(val, reg) __raw_writew((val) & 0xFF, &cpld->reg)
1867 +int easy98000_addon_has_dm9000(void)
1869 + if ((cpld_r8(idreg0) & 0xF) == 1)
1874 +#if defined(CONFIG_PROC_FS)
1875 +typedef void (*cpld_dump) (struct seq_file *s);
1876 +struct proc_entry {
1881 +static int cpld_proc_show ( struct seq_file *s, void *p )
1883 + cpld_dump dump = s->private;
1885 + if ( dump != NULL )
1891 +static int cpld_proc_open ( struct inode *inode, struct file *file )
1893 + return single_open ( file, cpld_proc_show, PDE(inode)->data );
1896 +static void cpld_versions_get ( struct seq_file *s )
1898 + seq_printf(s, "CPLD1: V%d\n", cpld_r8(cpld1v));
1899 + seq_printf(s, "CPLD2: V%d\n", cpld_r8(cpld2v));
1902 +static void cpld_ebu_module_get ( struct seq_file *s )
1906 + addon_id = cpld_r8(idreg0) & 0xF;
1907 + switch (addon_id) {
1908 + case 0xF: /* nothing connected */
1911 + seq_printf(s, "Ethernet Controller module (dm9000)\n");
1914 + seq_printf(s, "Unknown EBU module (EBU_ID=0x%02X)\n", addon_id);
1919 +static void cpld_xmii_module_get ( struct seq_file *s )
1924 + addon_id = cpld_r8(idreg1) & 0xF;
1925 + switch (addon_id) {
1927 + mod = "no module";
1930 + mod = "RGMII module";
1933 + mod = "GMII MAC Mode (XWAY TANTOS-3G)";
1936 + mod = "TMII MAC Mode (XWAY TANTOS-3G)";
1939 + mod = "GMII PHY module";
1942 + mod = "MII PHY module";
1945 + mod = "RMII PHY module";
1951 + seq_printf(s, "%s\n", mod);
1953 + seq_printf(s, "unknown xMII module (xMII_ID=0x%02X)\n", addon_id);
1956 +static struct proc_entry proc_entries[] = {
1957 + {"versions", cpld_versions_get},
1958 + {"ebu", cpld_ebu_module_get},
1959 + {"xmii", cpld_xmii_module_get},
1962 +static struct file_operations ops = {
1963 + .owner = THIS_MODULE,
1964 + .open = cpld_proc_open,
1966 + .llseek = seq_lseek,
1967 + .release = single_release,
1970 +static void cpld_proc_entry_create(struct proc_dir_entry *parent_node,
1971 + struct proc_entry *proc_entry)
1973 + proc_create_data ( proc_entry->name, (S_IFREG | S_IRUGO), parent_node,
1974 + &ops, proc_entry->callback);
1977 +static int cpld_proc_install(void)
1979 + struct proc_dir_entry *driver_proc_node;
1981 + driver_proc_node = proc_mkdir("cpld", NULL);
1982 + if (driver_proc_node != NULL) {
1984 + for (i = 0; i < ARRAY_SIZE(proc_entries); i++)
1985 + cpld_proc_entry_create(driver_proc_node,
1986 + &proc_entries[i]);
1988 + printk("cannot create proc entry");
1994 +static inline int cpld_proc_install(void) {}
1997 +static int easy98000_addon_probe(struct platform_device *pdev)
1999 + return cpld_proc_install();
2002 +static int easy98000_addon_remove(struct platform_device *pdev)
2004 +#if defined(CONFIG_PROC_FS)
2008 + for (i = 0; i < sizeof(proc_entries) / sizeof(proc_entries[0]); i++) {
2009 + sprintf(buf, "cpld/%s", proc_entries[i].name);
2010 + remove_proc_entry(buf, 0);
2012 + remove_proc_entry("cpld", 0);
2017 +static struct platform_driver easy98000_addon_driver = {
2018 + .probe = easy98000_addon_probe,
2019 + .remove = __devexit_p(easy98000_addon_remove),
2021 + .name = "easy98000_addon",
2022 + .owner = THIS_MODULE,
2026 +int __init easy98000_addon_init(void)
2028 + return platform_driver_register(&easy98000_addon_driver);
2031 +void __exit easy98000_addon_exit(void)
2033 + platform_driver_unregister(&easy98000_addon_driver);
2036 +module_init(easy98000_addon_init);
2037 +module_exit(easy98000_addon_exit);