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) += mach-easy98000.o
22 +++ b/arch/mips/lantiq/falcon/clk-falcon.c
25 + * This program is free software; you can redistribute it and/or modify
26 + * it under the terms of the GNU General Public License as published by
27 + * the Free Software Foundation; either version 2 of the License, or
28 + * (at your option) any later version.
30 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
33 +#include <linux/io.h>
34 +#include <linux/module.h>
35 +#include <linux/init.h>
37 +#include <asm/time.h>
39 +#include <asm/div64.h>
41 +#include <lantiq_soc.h>
44 +#include <gpon_reg_base.h>
45 +#include <sys1_reg.h>
47 +static struct gpon_reg_sys1 * const pSYS1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
50 +ltq_get_io_region_clock(void)
52 + return 200000000; /* 200 MHz */
54 +EXPORT_SYMBOL(ltq_get_io_region_clock);
59 + if ((ltq_r32(&pSYS1->cpu0cc) & CPU0CC_CPUDIV) == CPU0CC_CPUDIV_SELFHALF)
60 + return 200000000; /* 200 MHz */
62 + return 400000000; /* 400 MHz */
64 +EXPORT_SYMBOL(ltq_get_cpu_hz);
71 +EXPORT_SYMBOL(ltq_get_fpi_hz);
73 +++ b/arch/mips/lantiq/falcon/devices.c
75 +#include <linux/init.h>
76 +#include <linux/module.h>
77 +#include <linux/types.h>
78 +#include <linux/string.h>
79 +#include <linux/mtd/physmap.h>
80 +#include <linux/kernel.h>
81 +#include <linux/reboot.h>
82 +#include <linux/platform_device.h>
83 +#include <linux/leds.h>
84 +#include <linux/etherdevice.h>
85 +#include <linux/reboot.h>
86 +#include <linux/time.h>
87 +#include <linux/io.h>
88 +#include <linux/gpio.h>
89 +#include <linux/leds.h>
90 +#include <linux/spi/spi.h>
92 +#include <asm/bootinfo.h>
97 +#include <falcon/falcon_irq.h>
98 +#include <falcon/gpon_reg_base.h>
99 +#include <falcon/sys1_reg.h>
100 +#include <falcon/sys_eth_reg.h>
102 +#include <falcon/sysctrl.h>
104 +#include "devices.h"
106 +unsigned char ltq_ethaddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
107 +EXPORT_SYMBOL(ltq_ethaddr);
110 +falcon_set_ethaddr(char *str)
112 + sscanf(str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
113 + <q_ethaddr[0], <q_ethaddr[1], <q_ethaddr[2],
114 + <q_ethaddr[3], <q_ethaddr[4], <q_ethaddr[5]);
117 +__setup("ethaddr=", falcon_set_ethaddr);
120 +static struct resource falcon_asc0_resources[] =
122 + MEM_RES("asc0",GPON_ASC0_BASE,GPON_ASC0_END),
123 + IRQ_RES("tx",INT_NUM_IM3_IRL0),
124 + IRQ_RES("rx",INT_NUM_IM3_IRL0+1),
125 + IRQ_RES("err",INT_NUM_IM3_IRL0+2),
128 +static struct resource falcon_asc1_resources[] =
130 + MEM_RES("asc1",GPON_ASC1_BASE,GPON_ASC1_END),
131 + IRQ_RES("tx",INT_NUM_IM3_IRL0+8),
132 + IRQ_RES("rx",INT_NUM_IM3_IRL0+9),
133 + IRQ_RES("err",INT_NUM_IM3_IRL0+10),
136 +void __init falcon_register_asc(int port)
140 + platform_device_register_simple("ltq_asc", 0,
141 + falcon_asc0_resources, ARRAY_SIZE(falcon_asc0_resources));
144 + platform_device_register_simple("ltq_asc", 1,
145 + falcon_asc1_resources, ARRAY_SIZE(falcon_asc1_resources));
153 +static struct resource ltq_nor_resource =
154 + MEM_RES("nor",LTQ_FLASH_START,LTQ_FLASH_START + LTQ_FLASH_MAX - 1);
156 +static struct platform_device ltq_nor = {
158 + .resource = <q_nor_resource,
159 + .num_resources = 1,
162 +void __init falcon_register_nor(struct physmap_flash_data *data)
164 + ltq_nor.dev.platform_data = data;
165 + platform_device_register(<q_nor);
169 +static struct resource ltq_spi_resources[] = {
170 + MEM_RES("ebu", GPON_EBU_BASE, GPON_EBU_END),
171 + MEM_RES("sys1", GPON_SYS1_BASE, GPON_SYS1_END)
174 +static struct platform_device ltq_spi = {
175 + .name = "falcon_spi",
176 + .resource = ltq_spi_resources,
177 + .num_resources = ARRAY_SIZE(ltq_spi_resources)
180 +void __init falcon_register_spi_flash(struct spi_board_info *data)
182 + spi_register_board_info(data, 1);
183 + platform_device_register(<q_spi);
187 +static struct resource falcon_wdt_resource =
188 + MEM_RES("watchdog",GPON_WDT_BASE,GPON_WDT_END);
190 +void __init falcon_register_wdt(void)
192 + platform_device_register_simple("ltq_wdt", 0, &falcon_wdt_resource, 1);
196 +#define DECLARE_GPIO_RES(port) \
197 +static struct resource falcon_gpio ## port ## _resources[] = { \
198 + MEM_RES("gpio"#port,GPON_GPIO ## port ## _BASE,GPON_GPIO ## port ## _END), \
199 + MEM_RES("padctrl"#port,GPON_PADCTRL ## port ## _BASE,GPON_PADCTRL ## port ## _END), \
200 + IRQ_RES("gpio_mux"#port,FALCON_IRQ_GPIO_P ## port ) \
202 +DECLARE_GPIO_RES(0);
203 +DECLARE_GPIO_RES(1);
204 +DECLARE_GPIO_RES(2);
205 +#ifdef REGISTER_ALL_GPIO_PORTS
207 +#error NR_IRQS to low for all gpio irqs
209 +DECLARE_GPIO_RES(3);
210 +DECLARE_GPIO_RES(4);
213 +void __init falcon_register_gpio(void)
215 + platform_device_register_simple("falcon_gpio", 0,
216 + falcon_gpio0_resources, ARRAY_SIZE(falcon_gpio0_resources));
217 + platform_device_register_simple("falcon_gpio", 1,
218 + falcon_gpio1_resources, ARRAY_SIZE(falcon_gpio1_resources));
219 + platform_device_register_simple("falcon_gpio", 2,
220 + falcon_gpio2_resources, ARRAY_SIZE(falcon_gpio2_resources));
221 + sys1_hw_activate(ACTS_PADCTRL1 | ACTS_P1);
222 + sys_eth_hw_activate(SYS_ETH_ACTS_PADCTRL0 | SYS_ETH_ACTS_PADCTRL2 |
223 + SYS_ETH_ACTS_P0 | SYS_ETH_ACTS_P2);
225 +#ifdef REGISTER_ALL_GPIO_PORTS
226 + /* optional gpio ports: not registered,
227 + as the pins are EBU specific and always used by linux */
228 + platform_device_register_simple("falcon_gpio", 3,
229 + falcon_gpio3_resources, ARRAY_SIZE(falcon_gpio3_resources));
230 + platform_device_register_simple("falcon_gpio", 4,
231 + falcon_gpio4_resources, ARRAY_SIZE(falcon_gpio4_resources));
232 + sys1_hw_activate(ACTS_PADCTRL3 | ACTS_PADCTRL4 | ACTS_P3 | ACTS_P4);
236 +static struct resource falcon_i2c_resources[] = {
237 + MEM_RES("i2c", GPON_I2C_BASE,GPON_I2C_END),
238 + IRQ_RES("i2c_lb", FALCON_IRQ_I2C_LBREQ),
239 + IRQ_RES("i2c_b", FALCON_IRQ_I2C_BREQ),
240 + IRQ_RES("i2c_err", FALCON_IRQ_I2C_I2C_ERR),
241 + IRQ_RES("i2c_p", FALCON_IRQ_I2C_I2C_P),
244 +void __init falcon_register_i2c(void)
246 + platform_device_register_simple("i2c-falcon", 0,
247 + falcon_i2c_resources, ARRAY_SIZE(falcon_i2c_resources));
248 + sys1_hw_activate(ACTS_I2C_ACT);
251 +void __init falcon_register_crypto(void)
253 + platform_device_register_simple("ltq_falcon_deu", 0, NULL, 0);
256 +++ b/arch/mips/lantiq/falcon/devices.h
258 +#ifndef _FALCON_DEVICES_H__
259 +#define _FALCON_DEVICES_H__
261 +#include <linux/mtd/physmap.h>
262 +#include <linux/spi/spi.h>
263 +#include <linux/spi/flash.h>
265 +extern void __init falcon_register_asc(int port);
266 +extern void __init falcon_register_i2c(void);
267 +extern void __init falcon_register_spi_flash(struct spi_board_info *data);
268 +extern void __init falcon_register_gpio(void);
269 +extern void __init falcon_register_nor(struct physmap_flash_data *data);
270 +extern void __init falcon_register_wdt(void);
271 +extern void __init falcon_register_crypto(void);
273 +#define IRQ_RES(resname,irq) {.name=resname,.start=(irq),.flags=IORESOURCE_IRQ}
274 +#define MEM_RES(resname,adr_start,adr_end) \
275 + { .name=resname, .flags=IORESOURCE_MEM, \
276 + .start=((adr_start)&~KSEG1),.end=((adr_end)&~KSEG1) }
280 +++ b/arch/mips/lantiq/falcon/prom.c
283 + * This program is free software; you can redistribute it and/or modify
284 + * it under the terms of the GNU General Public License as published by
285 + * the Free Software Foundation; either version 2 of the License, or
286 + * (at your option) any later version.
288 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
291 +#include <linux/module.h>
292 +#include <linux/clk.h>
293 +#include <asm/bootinfo.h>
294 +#include <asm/time.h>
296 +#include <lantiq_soc.h>
300 +#include <falcon/gpon_reg_base.h>
301 +#include <falcon/status_reg.h>
302 +#include <falcon/sys1_reg.h>
304 +#include "../prom.h"
306 +static struct gpon_reg_status * const pSTATUS = (struct gpon_reg_status *)GPON_STATUS_BASE;
308 +#define SOC_FALCON "Falcon"
317 +ltq_soc_detect(struct ltq_soc_info *i)
319 + i->partnum = (ltq_r32(&pSTATUS->chipid) & STATUS_CHIPID_PARTNR_MASK) >> STATUS_CHIPID_PARTNR_OFFSET;
320 + i->rev = (ltq_r32(&pSTATUS->chipid) & STATUS_CHIPID_VERSION_MASK) >> STATUS_CHIPID_VERSION_OFFSET;
321 + switch (i->partnum)
323 + case SOC_ID_FALCON:
324 + i->name = SOC_FALCON;
325 + i->type = SOC_TYPE_FALCON;
329 + printk(KERN_ERR "unknown partnum : 0x%08X\n", i->partnum);
335 +++ b/arch/mips/lantiq/falcon/sysctrl.c
338 + * This program is free software; you can redistribute it and/or
339 + * modify it under the terms of the GNU General Public License as
340 + * published by the Free Software Foundation; either version 2 of
341 + * the License, or (at your option) any later version.
343 + * This program is distributed in the hope that it will be useful,
344 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
345 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
346 + * GNU General Public License for more details.
348 + * You should have received a copy of the GNU General Public License
349 + * along with this program; if not, write to the Free Software
350 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
351 + * MA 02111-1307 USA
353 + * Copyright (C) 2010 Thomas Langer, Lantiq Deutschland
356 +#include <linux/cpu.h>
357 +#include <linux/init.h>
358 +#include <linux/kernel.h>
359 +#include <linux/pm.h>
360 +#include <linux/io.h>
361 +#include <linux/ioport.h>
362 +#include <linux/clk.h>
363 +#include <asm/reboot.h>
365 +#include <falcon/gpon_reg_base.h>
366 +#include <falcon/status_reg.h>
367 +#include <falcon/sys1_reg.h>
368 +#include <falcon/sys_eth_reg.h>
369 +#include <falcon/sys_gpe_reg.h>
371 +#include <falcon/sysctrl.h>
373 +/* mapping to linux hw-accessor routines */
374 +#define reg_r32(reg) __raw_readl(reg)
375 +#define reg_w32(val, reg) __raw_writel(val, reg)
376 +#define reg_w32_mask(clear, set, reg) reg_w32((reg_r32(reg) & ~(clear)) | (set), reg)
378 +static struct gpon_reg_sys1 * const sys1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
379 +static struct gpon_reg_sys_eth * const sys_eth = (struct gpon_reg_sys_eth *)GPON_SYS_ETH_BASE;
380 +static struct gpon_reg_sys_gpe * const sys_gpe = (struct gpon_reg_sys_gpe *)GPON_SYS_GPE_BASE;
381 +static struct gpon_reg_status * const status = (struct gpon_reg_status *)GPON_STATUS_BASE;
384 + * Activate the selected module(s)
385 + * Enables the clock of the module and activates the module itself.
387 + * \param[in] mask bitmask of module(s), as for registers SYS1.ACT
390 +void sys1_hw_activate(u32 mask)
392 + sys1_w32(mask, clken);
393 + sys1_w32(mask, act);
395 + while ( (sys1_r32(acts) & mask) != mask) {
399 +EXPORT_SYMBOL(sys1_hw_activate);
402 + * Deactivate the selected module(s)
403 + * Disables the clock of the module and deactivates the module itself.
405 + * \param[in] mask bitmask of module(s), as for registers SYS1.DEACT
408 +void sys1_hw_deactivate(u32 mask)
410 + sys1_w32(mask, clkclr);
411 + sys1_w32(mask, deact);
413 + while ( (sys1_r32(acts) & mask) != 0) {
417 +EXPORT_SYMBOL(sys1_hw_deactivate);
420 + * Clock enable for the selected module(s)
421 + * Enables the clock of the module.
423 + * \param[in] mask bitmask of module(s), as for registers SYS1.CLKEN
426 +void sys1_hw_clk_enable(u32 mask)
428 + sys1_w32(mask, clken);
430 + while ( (sys1_r32(clks) & mask) != mask) {
434 +EXPORT_SYMBOL(sys1_hw_clk_enable);
437 + * Clock disable for the selected module(s)
438 + * disables the clock of the module.
440 + * \param[in] mask bitmask of module(s), as for registers SYS1.CLKCLR
443 +void sys1_hw_clk_disable(u32 mask)
445 + sys1_w32(mask, clkclr);
447 + while ( (sys1_r32(clks) & mask) != 0) {
451 +EXPORT_SYMBOL(sys1_hw_clk_disable);
454 + * Reboots the selected module(s)
455 + * Triggers the reboot of the module.
457 + * \param[in] mask bitmask of module(s), as for registers SYS1.RBT
460 +void sys1_hw_activate_or_reboot(u32 mask)
462 + u32 acts = sys1_r32(acts);
463 + /* is not already active? */
464 + if ((~acts & mask) != 0)
465 + sys1_hw_activate(~acts & mask);
466 + sys1_w32(acts & mask, rbt);
467 + while ( (sys1_r32(acts) & mask) != mask) {
471 +EXPORT_SYMBOL(sys1_hw_activate_or_reboot);
474 + * Activate the selected module(s)
475 + * Enables the clock of the module and activates the module itself.
477 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.ACT
480 +void sys_eth_hw_activate(u32 mask)
482 + sys_eth_w32(mask, clken);
483 + sys_eth_w32(mask, act);
485 + while ( (sys_eth_r32(acts) & mask) != mask) {
489 +EXPORT_SYMBOL(sys_eth_hw_activate);
492 + * Deactivate the selected module(s)
493 + * Disables the clock of the module and deactivates the module itself.
495 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.DEACT
498 +void sys_eth_hw_deactivate(u32 mask)
500 + sys_eth_w32(mask, clkclr);
501 + sys_eth_w32(mask, deact);
503 + while ( (sys_eth_r32(acts) & mask) != 0) {
507 +EXPORT_SYMBOL(sys_eth_hw_deactivate);
510 + * Clock enable for the selected module(s)
511 + * Enables the clock of the module.
513 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.CLKEN
516 +void sys_eth_hw_clk_enable(u32 mask)
518 + sys_eth_w32(mask, clken);
520 + while ( (sys_eth_r32(clks) & mask) != mask) {
524 +EXPORT_SYMBOL(sys_eth_hw_clk_enable);
527 + * Clock disable for the selected module(s)
528 + * disables the clock of the module.
530 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.CLKCLR
533 +void sys_eth_hw_clk_disable(u32 mask)
535 + sys_eth_w32(mask, clkclr);
537 + while ( (sys_eth_r32(clks) & mask) != 0) {
541 +EXPORT_SYMBOL(sys_eth_hw_clk_disable);
544 + * Reboots the selected module(s)
545 + * Triggers the reboot of the module.
547 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.RBT
550 +void sys_eth_hw_activate_or_reboot(u32 mask)
552 + u32 acts = sys_eth_r32(acts);
553 + /* is not already active? */
554 + if ((~acts & mask) != 0)
555 + sys_eth_hw_activate(~acts & mask);
556 + sys_eth_w32(acts & mask, rbt);
557 + while ( (sys_eth_r32(acts) & mask) != mask) {
561 +EXPORT_SYMBOL(sys_eth_hw_activate_or_reboot);
563 +static int gpe_clk_is_enabled(void)
567 + rd_data = sys1_r32(infrac);
568 + if (rd_data & (1<<(INFRAC_GP_OFFSET+1)))
573 +static void enable_gpe_clk(void)
577 + u32 rd_data_to_keep;
580 + if (gpe_clk_is_enabled())
581 + /* clock already active, no need to change here */
584 + if (status_r32(config) == 0)
585 + aeFreq = 1; /* use 625MHz on unfused chip */
587 + aeFreq = (status_r32(config) & STATUS_CONFIG_GPEFREQ_MASK) >> STATUS_CONFIG_GPEFREQ_OFFSET;
588 + rd_data = sys1_r32(infrac);
589 + /* clear gpe-fsel and enable bits */
590 + rd_data_to_keep = rd_data & ~(7<<(INFRAC_GP_OFFSET+1));
593 + sys1_w32(rd_data_to_keep | (aeFreq<<(INFRAC_GP_OFFSET+2)), infrac);
595 + for (i = 0; i <10; i++) /* wait 10 cycles */
598 + /* keep new fsel and enable */
599 + sys1_w32(rd_data_to_keep | (aeFreq<<(INFRAC_GP_OFFSET+2)) |
600 + (1<<(INFRAC_GP_OFFSET+1)), infrac);
601 + for (i = 0; i <100; i++) /* wait 100 cycles */
606 + * Activate the selected module(s)
607 + * Enables the clock of the module and activates the module itself.
609 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.ACT
612 +void sys_gpe_hw_activate(u32 mask)
615 + sys_gpe_w32(mask, clken);
616 + sys_gpe_w32(mask, act);
618 + while ( (sys_gpe_r32(acts) & mask) != mask) {
622 +EXPORT_SYMBOL(sys_gpe_hw_activate);
625 + * Deactivate the selected module(s)
626 + * Disables the clock of the module and deactivates the module itself.
628 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.DEACT
631 +void sys_gpe_hw_deactivate(u32 mask)
634 + sys_gpe_w32(mask, clkclr);
635 + sys_gpe_w32(mask, deact);
637 + while ( (sys_gpe_r32(acts) & mask) != 0) {
641 +EXPORT_SYMBOL(sys_gpe_hw_deactivate);
644 + * Clock enable for the selected module(s)
645 + * Enables the clock of the module.
647 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.CLKEN
650 +void sys_gpe_hw_clk_enable(u32 mask)
653 + sys_gpe_w32(mask, clken);
655 + while ( (sys_gpe_r32(clks) & mask) != mask) {
659 +EXPORT_SYMBOL(sys_gpe_hw_clk_enable);
662 + * Clock disable for the selected module(s)
663 + * disables the clock of the module.
665 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.CLKCLR
668 +void sys_gpe_hw_clk_disable(u32 mask)
671 + sys_gpe_w32(mask, clkclr);
673 + while ( (sys_gpe_r32(clks) & mask) != 0) {
677 +EXPORT_SYMBOL(sys_gpe_hw_clk_disable);
680 + * Reboots the selected module(s)
681 + * Triggers the reboot of the module.
683 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.RBT
686 +void sys_gpe_hw_activate_or_reboot(u32 mask)
690 + acts = sys_gpe_r32(acts);
691 + /* is not already active? */
692 + if ((~acts & mask) != 0)
693 + sys_gpe_hw_activate(~acts & mask);
694 + sys_gpe_w32(acts & mask, rbt);
695 + while ( (sys_gpe_r32(acts) & mask) != mask) {
699 +EXPORT_SYMBOL(sys_gpe_hw_activate_or_reboot);
702 + * Retrieve activation status of the selected hardware module(s)
704 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.RBT
705 + * \return int 1 - if hardware module(s) is activated (including clock)
707 + int sys_gpe_hw_is_activated(u32 mask)
709 + if (gpe_clk_is_enabled() == 0)
712 + if ((sys_gpe_r32(clks) & mask) != mask)
715 + return ((sys_gpe_r32(acts) & mask) == mask);
717 +EXPORT_SYMBOL(sys_gpe_hw_is_activated);
719 +++ b/arch/mips/lantiq/falcon/gpio.c
722 + * This program is free software; you can redistribute it and/or modify
723 + * it under the terms of the GNU General Public License as published by
724 + * the Free Software Foundation; either version 2 of the License, or
725 + * (at your option) any later version.
727 + * This program is distributed in the hope that it will be useful,
728 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
729 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
730 + * GNU General Public License for more details.
732 + * You should have received a copy of the GNU General Public License
733 + * along with this program; if not, write to the Free Software
734 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
736 + * Copyright (C) 2010 Thomas Langer, Lantiq Deutschland
742 + - provide mask of available pins per platform_data
745 +#include <linux/module.h>
746 +#include <linux/types.h>
747 +#include <linux/errno.h>
748 +#include <linux/init.h>
749 +#include <linux/seq_file.h>
750 +#include <linux/platform_device.h>
751 +#include <linux/uaccess.h>
752 +#include <linux/gpio.h>
753 +#include <linux/irq.h>
754 +#include <linux/interrupt.h>
755 +#include <linux/slab.h>
758 +#include <falcon/falcon_irq.h>
760 +#include <linux/version.h>
761 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
762 +#define for_each_set_bit for_each_bit
765 +#define gpio_r32(reg) __raw_readl(reg)
766 +#define gpio_w32(val, reg) __raw_writel(val, reg)
767 +#define gpio_w32_mask(clear, set, reg) gpio_w32((gpio_r32(reg) & ~(clear)) | (set), reg)
770 +/** register structure for padctrl
771 + (mainly needed for mux control) */
772 +typedef struct gpon_padctrl_s
774 + /** Multiplexer Control Register
775 + 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). */
776 + unsigned int muxc[32];
777 + /** Pull Up Enable Register */
778 + unsigned int puen; /* 0x00000080 */
779 + /** Pull Down Enable Register */
780 + unsigned int pden; /* 0x00000084 */
781 + /** Slew Rate Control Register */
782 + unsigned int src; /* 0x00000088 */
783 + /** Drive Current Control Register */
784 + unsigned int dcc; /* 0x0000008C */
786 + unsigned int res_0[24]; /* 0x00000090 */
787 + /** Pad Control Availability Register */
788 + unsigned int avail; /* 0x000000F0 */
791 +/** register structure for gpio port */
792 +typedef struct gpon_gpio_s
794 + /** Data Output Register
795 + Via this register the output values of the different bits can be set if they are switched as outputs. */
796 + unsigned int out; /* 0x00000000 */
797 + /** Data Input Register
798 + Via this register the input values of the different bits can be observed. */
799 + unsigned int in; /* 0x00000004 */
800 + /** Direction Register
801 + Via this register the input direction of the different bits can be determined. */
802 + unsigned int dir; /* 0x00000008 */
804 + unsigned int res_0[3]; /* 0x0000000C */
805 + /** External Interrupt Control Register 0 */
806 + unsigned int exintcr0; /* 0x00000018 */
807 + /** External Interrupt Control Register 1 */
808 + unsigned int exintcr1; /* 0x0000001C */
809 + /** IRN Capture Register
810 + 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. */
811 + unsigned int irncr; /* 0x00000020 */
812 + /** IRN Interrupt Control Register
813 + 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. */
814 + unsigned int irnicr; /* 0x00000024 */
815 + /** IRN Interrupt Enable Register
816 + 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. */
817 + unsigned int irnen; /* 0x00000028 */
818 + /** IRN Interrupt Configuration Register
819 + Configures the interrupts bitwise to be edge-senstivie or level-sensitive. */
820 + unsigned int irncfg; /* 0x0000002C */
821 + /** IRN Interrupt Enable Set Register
822 + The corresponding bit in the IRNEN register can be set with an atomic access. */
823 + unsigned int irnenset; /* 0x00000030 */
824 + /** IRN Interrupt Enable Clear Register
825 + The corresponding bit in the IRNEN register can be cleared with an atomic access. */
826 + unsigned int irnenclr; /* 0x00000034 */
828 + unsigned int res_1[2]; /* 0x00000038 */
829 + /** Output Set Register
830 + This register can be used to set certain bits within the OUT register without touching the other bits. */
831 + unsigned int outset; /* 0x00000040 */
832 + /** Output Clear Register
833 + This register can be used to clear certain bits within the OUT register without touching the other bits. */
834 + unsigned int outclr; /* 0x00000044 */
835 + /** Direction Set Register
836 + This register can be used to set certain bits within the DIR register without touching the other bits. */
837 + unsigned int dirset; /* 0x00000048 */
838 + /** Direction Clear Register
839 + This register can be used to clear certain bits within the DIR register without touching the other bits. */
840 + unsigned int dirclr; /* 0x0000004C */
843 +struct falcon_gpio_port {
844 + struct gpio_chip gpio_chip;
845 + gpon_padctrl0_t __iomem *pad;
846 + gpon_gpio_t __iomem *port;
847 + struct resource *pad_req; /* resources requested */
848 + struct resource *port_req;
849 + unsigned int irq_base;
850 + unsigned int chained_irq;
853 +static int gpio_exported = 0;
854 +static int __init gpio_export_setup(char *str)
856 + get_option(&str, &gpio_exported);
859 +__setup("gpio_exported=", gpio_export_setup);
861 +static inline struct falcon_gpio_port *to_falcon_gpio_port(struct gpio_chip *chip)
863 + return container_of(chip, struct falcon_gpio_port, gpio_chip);
866 +static int falcon_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
868 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
869 + gpio_w32(1<<offset, &gpio_port->port->dirclr);
873 +static int falcon_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, int value)
875 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
876 + gpio_w32(1<<offset, &gpio_port->port->dirset);
880 +static void falcon_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
882 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
884 + gpio_w32(1<<offset, &gpio_port->port->outset);
886 + gpio_w32(1<<offset, &gpio_port->port->outclr);
889 +static int falcon_gpio_get(struct gpio_chip *chip, unsigned int offset)
891 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
892 + if ((gpio_r32(&gpio_port->port->dir) >> offset) & 1)
893 + return (gpio_r32(&gpio_port->port->out) >> offset) & 1;
895 + return (gpio_r32(&gpio_port->port->in) >> offset) & 1;
898 +static int falcon_gpio_request(struct gpio_chip *chip, unsigned offset)
900 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
901 + if ( (gpio_r32(&gpio_port->pad->avail) >> offset) & 1) {
902 + if (gpio_r32(&gpio_port->pad->muxc[offset]) > 1)
904 + /* switch on gpio function */
905 + gpio_w32(1, &gpio_port->pad->muxc[offset]);
912 +static void falcon_gpio_free(struct gpio_chip *chip, unsigned offset)
914 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
915 + if ( (gpio_r32(&gpio_port->pad->avail) >> offset) & 1) {
916 + if (gpio_r32(&gpio_port->pad->muxc[offset]) > 1)
918 + /* switch off gpio function */
919 + gpio_w32(0, &gpio_port->pad->muxc[offset]);
923 +static int falcon_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
925 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
926 + /* no checks: this functions is only registered with valid irq_base */
927 + return gpio_port->irq_base + offset;
930 +static void falcon_gpio_disable_irq(struct irq_data *d)
932 + struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
933 + unsigned int offset = d->irq-gpio_port->irq_base;
934 + gpio_w32(1<<offset, &gpio_port->port->irnenclr);
937 +static void falcon_gpio_enable_irq(struct irq_data *d)
939 + struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
940 + unsigned int offset = d->irq-gpio_port->irq_base;
942 + if (gpio_r32(&gpio_port->pad->muxc[offset]) < 1) {
943 + /* switch on gpio function */
944 + gpio_w32(1, &gpio_port->pad->muxc[offset]);
947 + gpio_w32(1<<offset, &gpio_port->port->irnenset);
950 +static void falcon_gpio_ack_irq(struct irq_data *d)
952 + struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
953 + unsigned int offset = d->irq-gpio_port->irq_base;
954 + gpio_w32(1<<offset, &gpio_port->port->irncr);
957 +static void falcon_gpio_mask_and_ack_irq(struct irq_data *d)
959 + struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
960 + unsigned int offset = d->irq-gpio_port->irq_base;
961 + gpio_w32(1<<offset, &gpio_port->port->irnenclr);
962 + gpio_w32(1<<offset, &gpio_port->port->irncr);
965 +static struct irq_chip falcon_gpio_irq_chip;
966 +static int falcon_gpio_irq_type(struct irq_data *d, unsigned int type)
968 + struct falcon_gpio_port *gpio_port = irq_get_chip_data(d->irq);
969 + unsigned int offset = d->irq-gpio_port->irq_base;
970 + unsigned int mask = 1 << offset;
972 + if ((type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_NONE)
975 + if ((type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) != 0) {
976 + /* level triggered */
977 + gpio_w32_mask(0, mask, &gpio_port->port->irncfg);
978 + irq_set_chip_and_handler_name(d->irq,
979 + &falcon_gpio_irq_chip, handle_level_irq, "mux");
981 + /* edge triggered */
982 + gpio_w32_mask(mask, 0, &gpio_port->port->irncfg);
983 + irq_set_chip_and_handler_name(d->irq,
984 + &falcon_gpio_irq_chip, handle_simple_irq, "mux");
987 + if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
988 + gpio_w32_mask(mask, 0, &gpio_port->port->exintcr0);
989 + gpio_w32_mask(0, mask, &gpio_port->port->exintcr1);
991 + if ((type & (IRQ_TYPE_EDGE_RISING |IRQ_TYPE_LEVEL_HIGH)) != 0) {
992 + /* positive logic: rising edge, high level */
993 + gpio_w32_mask(mask, 0, &gpio_port->port->exintcr0);
995 + /* negative logic: falling edge, low level */
996 + gpio_w32_mask(0, mask, &gpio_port->port->exintcr0);
998 + gpio_w32_mask(mask, 0, &gpio_port->port->exintcr1);
1001 + return gpio_direction_input(gpio_port->gpio_chip.base + offset);
1004 +static void falcon_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
1006 + struct falcon_gpio_port *gpio_port = irq_desc_get_handler_data(desc);
1007 + unsigned long irncr;
1010 + irncr = gpio_r32(&gpio_port->port->irncr);
1011 + /* acknowledge interrupt */
1012 + gpio_w32(irncr, &gpio_port->port->irncr);
1014 + desc->irq_data.chip->irq_ack(&desc->irq_data);
1016 + for_each_set_bit(offset, &irncr, gpio_port->gpio_chip.ngpio)
1017 + generic_handle_irq(gpio_port->irq_base + offset);
1020 +static struct irq_chip falcon_gpio_irq_chip = {
1021 + .name = "gpio_irq_mux",
1022 + .irq_mask = falcon_gpio_disable_irq,
1023 + .irq_unmask = falcon_gpio_enable_irq,
1024 + .irq_ack = falcon_gpio_ack_irq,
1025 + .irq_mask_ack = falcon_gpio_mask_and_ack_irq,
1026 + .irq_set_type = falcon_gpio_irq_type,
1029 +static struct irqaction gpio_cascade = {
1030 + .handler = no_action,
1031 + .flags = IRQF_DISABLED,
1032 + .name = "gpio_cascade",
1035 +static int falcon_gpio_probe(struct platform_device *pdev)
1037 + struct falcon_gpio_port *gpio_port;
1039 + struct resource *gpiores, *padres;
1042 + gpiores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1043 + padres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1044 + irq = platform_get_irq(pdev, 0);
1045 + if (!gpiores || !padres)
1048 + gpio_port = kzalloc(sizeof(*gpio_port), GFP_KERNEL);
1049 + if (gpio_port == NULL)
1052 + gpio_port->gpio_chip.label = "falcon-gpio";
1053 + gpio_port->gpio_chip.direction_input = falcon_gpio_direction_input;
1054 + gpio_port->gpio_chip.direction_output = falcon_gpio_direction_output;
1055 + gpio_port->gpio_chip.get = falcon_gpio_get;
1056 + gpio_port->gpio_chip.set = falcon_gpio_set;
1057 + gpio_port->gpio_chip.request = falcon_gpio_request;
1058 + gpio_port->gpio_chip.free = falcon_gpio_free;
1059 + gpio_port->gpio_chip.base = 100 * pdev->id;
1060 + gpio_port->gpio_chip.ngpio = 32;
1061 + gpio_port->gpio_chip.dev = &pdev->dev;
1062 + gpio_port->gpio_chip.exported = gpio_exported;
1064 + gpio_port->port_req = request_mem_region(gpiores->start,
1065 + resource_size(gpiores), pdev->name);
1066 + gpio_port->pad_req = request_mem_region(padres->start,
1067 + resource_size(padres), pdev->name);
1068 + if (!gpio_port->port_req || !gpio_port->pad_req) {
1069 + dev_err(&pdev->dev, "cannot claim register area\n");
1074 + gpio_port->port = ioremap_nocache(gpiores->start,
1075 + resource_size(gpiores));
1076 + gpio_port->pad = ioremap_nocache(padres->start,
1077 + resource_size(padres));
1078 + if (!gpio_port->port || !gpio_port->pad) {
1079 + dev_err(&pdev->dev, "Could not map io ranges\n");
1086 + * irq_chip support
1088 + gpio_port->gpio_chip.to_irq = falcon_gpio_to_irq;
1089 + gpio_port->irq_base = INT_NUM_EXTRA_START + 32 * pdev->id;
1091 + for (i = 0; i < 32; i++) {
1092 + irq_set_chip_and_handler_name(gpio_port->irq_base + i,
1093 + &falcon_gpio_irq_chip, handle_simple_irq, "mux");
1094 + irq_set_chip_data(gpio_port->irq_base + i, gpio_port);
1095 + /* FIXME: set default cfg to level triggered */
1096 + //gpio_w32_mask(0, 1<<i, &gpio_port->port->irncfg);
1097 + /* set to negative logic (falling edge, low level) */
1098 + gpio_w32_mask(0, 1<<i, &gpio_port->port->exintcr0);
1101 + gpio_port->chained_irq = irq;
1102 + setup_irq(irq, &gpio_cascade);
1103 + irq_set_handler_data(irq, gpio_port);
1104 + irq_set_chained_handler(irq, falcon_gpio_irq_handler);
1107 + ret = gpiochip_add(&gpio_port->gpio_chip);
1109 + dev_err(&pdev->dev, "Could not register gpiochip %d, %d\n",
1113 + platform_set_drvdata(pdev, gpio_port);
1117 + dev_err(&pdev->dev, "Error in gpio_probe %d, %d\n", pdev->id, ret);
1118 + if (gpio_port->port_req)
1119 + release_resource(gpio_port->port_req);
1120 + if (gpio_port->pad_req)
1121 + release_resource(gpio_port->pad_req);
1123 + if (gpio_port->port)
1124 + iounmap(gpio_port->port);
1125 + if (gpio_port->pad)
1126 + iounmap(gpio_port->pad);
1131 +static int falcon_gpio_remove(struct platform_device *pdev)
1133 + struct falcon_gpio_port *gpio_port = platform_get_drvdata(pdev);
1136 + ret = gpiochip_remove(&gpio_port->gpio_chip);
1137 + if (gpio_port->port_req)
1138 + release_resource(gpio_port->port_req);
1139 + if (gpio_port->pad_req)
1140 + release_resource(gpio_port->pad_req);
1141 + if (gpio_port->port)
1142 + iounmap(gpio_port->port);
1143 + if (gpio_port->pad)
1144 + iounmap(gpio_port->pad);
1151 +static struct platform_driver falcon_gpio_driver = {
1152 + .probe = falcon_gpio_probe,
1153 + .remove = __devexit_p(falcon_gpio_remove),
1155 + .name = "falcon_gpio",
1156 + .owner = THIS_MODULE,
1160 +int __init falcon_gpio_init(void)
1164 + printk(KERN_INFO "FALC(tm) ON GPIO Driver, (C) 2011 Lantiq Deutschland Gmbh\n");
1165 + ret = platform_driver_register(&falcon_gpio_driver);
1167 + pr_err( "falcon_gpio: Error registering platform driver!");
1171 +void __exit falcon_gpio_exit(void)
1173 + platform_driver_unregister(&falcon_gpio_driver);
1176 +int gpio_to_irq(unsigned int gpio)
1178 + return __gpio_to_irq(gpio);
1180 +EXPORT_SYMBOL(gpio_to_irq);
1182 +module_init(falcon_gpio_init);
1183 +module_exit(falcon_gpio_exit);
1185 +++ b/arch/mips/include/asm/mach-lantiq/falcon/falcon.h
1188 + * This program is free software; you can redistribute it and/or modify
1189 + * it under the terms of the GNU General Public License as published by
1190 + * the Free Software Foundation; either version 2 of the License, or
1191 + * (at your option) any later version.
1193 + * Copyright (C) 2005 infineon
1194 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
1197 +#ifdef CONFIG_SOC_FALCON
1199 +#include <lantiq_soc.h>
1200 +#include <falcon/gpon_reg_base.h>
1204 +++ b/arch/mips/lantiq/falcon/reset.c
1207 + * This program is free software; you can redistribute it and/or modify
1208 + * it under the terms of the GNU General Public License as published by
1209 + * the Free Software Foundation; either version 2 of the License, or
1210 + * (at your option) any later version.
1212 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
1215 +#include <linux/init.h>
1216 +#include <linux/io.h>
1217 +#include <linux/pm.h>
1218 +#include <asm/reboot.h>
1219 +#include <linux/module.h>
1221 +#include <falcon.h>
1222 +#include <falcon/gpon_reg_base.h>
1223 +#include <falcon/status_reg.h>
1224 +#include <falcon/sys1_reg.h>
1226 +static struct gpon_reg_sys1 * const pSYS1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
1228 +#define WDT_PW1 0x00BE0000
1229 +#define WDT_PW2 0x00DC0000
1230 +#define WDT_REG_BASE (KSEG1 | 0x1F8803F0)
1232 +/* This function is used by the watchdog driver */
1233 +int ltq_reset_cause(void)
1237 +EXPORT_SYMBOL_GPL(ltq_reset_cause);
1240 +ltq_machine_restart(char *command)
1242 + printk(KERN_NOTICE "System restart\n");
1243 + local_irq_disable();
1244 + ltq_w32(0, (void*)0xBF200000); /* reset Bootreg RVEC */
1246 + ltq_w32(RBT_CPU_TRIG, &pSYS1->rbt);
1248 + /* use workaround via watchdog timer */
1249 + ltq_w32(WDT_PW1, (void*)WDT_REG_BASE);
1251 + (0x3 << 26) | /* PWL */
1252 + (0x2 << 24) | /* CLKDIV */
1253 + (0x1 << 31) | /* enable */
1255 + (void*)WDT_REG_BASE);
1261 +ltq_machine_halt(void)
1263 + printk(KERN_NOTICE "System halted.\n");
1264 + local_irq_disable();
1269 +ltq_machine_power_off(void)
1271 + printk(KERN_NOTICE "Please turn off the power now.\n");
1272 + local_irq_disable();
1277 +mips_reboot_setup(void)
1279 + _machine_restart = ltq_machine_restart;
1280 + _machine_halt = ltq_machine_halt;
1281 + pm_power_off = ltq_machine_power_off;
1285 +arch_initcall(mips_reboot_setup);
1287 +++ b/arch/mips/lantiq/falcon/mach-easy98000.c
1289 +#include <linux/init.h>
1290 +#include <linux/platform_device.h>
1291 +#include <linux/leds.h>
1292 +#include <linux/gpio.h>
1293 +#include <linux/gpio_buttons.h>
1294 +#include <linux/etherdevice.h>
1295 +#include <linux/mtd/mtd.h>
1296 +#include <linux/mtd/partitions.h>
1297 +#include <linux/mtd/physmap.h>
1298 +#include <linux/input.h>
1299 +#include <linux/interrupt.h>
1300 +#include <linux/dm9000.h>
1301 +#include <linux/i2c.h>
1302 +#include <linux/i2c-gpio.h>
1303 +#include <linux/spi/spi.h>
1304 +#include <linux/spi/spi_gpio.h>
1305 +#include <linux/spi/eeprom.h>
1307 +#include "../machtypes.h"
1309 +#include "devices.h"
1310 +#include "dev-leds-gpio.h"
1312 +#define EASY98000_GPIO_LED_0 9
1313 +#define EASY98000_GPIO_LED_1 10
1314 +#define EASY98000_GPIO_LED_2 11
1315 +#define EASY98000_GPIO_LED_3 12
1316 +#define EASY98000_GPIO_LED_4 13
1317 +#define EASY98000_GPIO_LED_5 14
1319 +extern unsigned char ltq_ethaddr[6];
1321 +#ifdef CONFIG_MTD_PARTITIONS
1322 +static struct mtd_partition easy98000_nor_partitions[] =
1330 + .name = "uboot_env",
1331 + .offset = 0x40000,
1332 + .size = 0x40000, /* 2 sectors for redundant env. */
1336 + .offset = 0x80000,
1337 + .size = 0xF80000, /* map only 16 MiB */
1342 +static struct physmap_flash_data easy98000_nor_flash_data = {
1343 +#ifdef CONFIG_MTD_PARTITIONS
1344 + .nr_parts = ARRAY_SIZE(easy98000_nor_partitions),
1345 + .parts = easy98000_nor_partitions,
1349 +#ifdef CONFIG_MTD_PARTITIONS
1350 +static struct flash_platform_data easy98000_spi_flash_platform_data = {
1352 + .parts = easy98000_nor_partitions,
1353 + .nr_parts = ARRAY_SIZE(easy98000_nor_partitions)
1357 +static struct spi_board_info easy98000_spi_flash_data __initdata = {
1358 + .modalias = "m25p80",
1361 + .max_speed_hz = 10 * 1000 * 1000,
1362 + .mode = SPI_MODE_3,
1363 +#ifdef CONFIG_MTD_PARTITIONS
1364 + .platform_data = &easy98000_spi_flash_platform_data
1368 +static struct gpio_led easy98000_leds_gpio[] __initdata = {
1370 + .name = "easy98000:green:0",
1371 + .gpio = EASY98000_GPIO_LED_0,
1374 + .name = "easy98000:green:1",
1375 + .gpio = EASY98000_GPIO_LED_1,
1378 + .name = "easy98000:green:2",
1379 + .gpio = EASY98000_GPIO_LED_2,
1382 + .name = "easy98000:green:3",
1383 + .gpio = EASY98000_GPIO_LED_3,
1386 + .name = "easy98000:green:4",
1387 + .gpio = EASY98000_GPIO_LED_4,
1390 + .name = "easy98000:green:5",
1391 + .gpio = EASY98000_GPIO_LED_5,
1396 +#define CONFIG_DM9000_BASE 0x14000000
1397 +#define DM9000_IO (CONFIG_DM9000_BASE + 3)
1398 +#define DM9000_DATA (CONFIG_DM9000_BASE + 1)
1400 +static struct dm9000_plat_data dm9000_plat_data = {
1401 + .flags = DM9000_PLATF_8BITONLY,
1402 + //.dev_addr = { }, /* possibility to provide an ethernet address for the chip */
1405 +static struct resource dm9000_resources[] = {
1406 + MEM_RES("dm9000_io", DM9000_IO, DM9000_IO),
1407 + MEM_RES("dm9000_data", DM9000_DATA, DM9000_DATA),
1409 + /* with irq (210 -> gpio 110) the driver is very unreliable */
1410 + .start = -1, /* use polling */
1412 + .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
1416 +static struct platform_device dm9000_platform = {
1419 + .num_resources = ARRAY_SIZE(dm9000_resources),
1420 + .resource = dm9000_resources,
1422 + .platform_data = (void *) &dm9000_plat_data,
1426 +static void __init register_davicom(void)
1428 + if (!is_valid_ether_addr(ltq_ethaddr))
1429 + random_ether_addr(dm9000_plat_data.dev_addr);
1431 + memcpy(dm9000_plat_data.dev_addr, ltq_ethaddr, 6);
1432 + /* change to "Locally Administered Address" */
1433 + dm9000_plat_data.dev_addr[0] |= 0x2;
1435 + platform_device_register(&dm9000_platform);
1438 +static struct i2c_gpio_platform_data easy98000_i2c_gpio_data = {
1443 +static struct platform_device easy98000_i2c_gpio_device = {
1444 + .name = "i2c-gpio",
1447 + .platform_data = &easy98000_i2c_gpio_data,
1451 +void __init register_easy98000_cpld_led(void)
1453 + platform_device_register_simple("easy98000_cpld_led", 0, NULL, 0);
1456 +/* setup gpio based spi bus/device for access to the eeprom on the board */
1457 +#define SPI_GPIO_MRST 102
1458 +#define SPI_GPIO_MTSR 103
1459 +#define SPI_GPIO_CLK 104
1460 +#define SPI_GPIO_CS0 105
1461 +#define SPI_GPIO_CS1 106
1462 +#define SPI_GPIO_BUS_NUM 1
1464 +static struct spi_gpio_platform_data easy98000_spi_gpio_data = {
1465 + .sck = SPI_GPIO_CLK,
1466 + .mosi = SPI_GPIO_MTSR,
1467 + .miso = SPI_GPIO_MRST,
1468 + .num_chipselect = 2,
1471 +static struct platform_device easy98000_spi_gpio_device = {
1472 + .name = "spi_gpio",
1473 + .id = SPI_GPIO_BUS_NUM,
1474 + .dev.platform_data = &easy98000_spi_gpio_data,
1477 +static struct spi_eeprom at25160n = {
1478 + .byte_len = 16 * 1024 / 8,
1479 + .name = "at25160n",
1481 + .flags = EE_ADDR2,
1484 +static struct spi_board_info easy98000_spi_gpio_devices __initdata = {
1485 + .modalias = "at25",
1486 + .bus_num = SPI_GPIO_BUS_NUM,
1487 + .max_speed_hz = 1000 * 1000,
1488 + .mode = SPI_MODE_3,
1490 + .controller_data = (void *) SPI_GPIO_CS1,
1491 + .platform_data = &at25160n,
1494 +static void __init easy98000_spi_gpio_init(void)
1496 + spi_register_board_info(&easy98000_spi_gpio_devices, 1);
1497 + platform_device_register(&easy98000_spi_gpio_device);
1500 +static void __init easy98000_init_common(void)
1502 + falcon_register_asc(0);
1503 + falcon_register_gpio();
1504 + falcon_register_wdt();
1505 + falcon_register_i2c();
1506 + platform_device_register(&easy98000_i2c_gpio_device);
1507 + register_davicom();
1508 + ltq_add_device_leds_gpio(-1, ARRAY_SIZE(easy98000_leds_gpio),
1509 + easy98000_leds_gpio);
1510 + register_easy98000_cpld_led();
1511 + falcon_register_crypto();
1512 + easy98000_spi_gpio_init();
1515 +static void __init easy98000_init(void)
1517 + easy98000_init_common();
1518 + falcon_register_nor(&easy98000_nor_flash_data);
1521 +static void __init easy98000sf_init(void)
1523 + easy98000_init_common();
1524 + falcon_register_spi_flash(&easy98000_spi_flash_data);
1527 +MIPS_MACHINE(LANTIQ_MACH_EASY98000,
1529 + "EASY98000 Eval Board",
1532 +MIPS_MACHINE(LANTIQ_MACH_EASY98000SF,
1534 + "EASY98000 Eval Board (Serial Flash)",
1535 + easy98000sf_init);
1537 +++ b/arch/mips/lantiq/falcon/softdog_vpe.c
1540 +** =============================================================================
1541 +** FILE NAME : softdog_vpe.c
1543 +** DATE : 24-03-2008
1544 +** AUTHOR : LXDB Team
1545 +** DESCRIPTION : This header file contains the code for the watchdog
1546 +** implentation on vpe1 side.
1548 +** COPYRIGHT : Copyright (c) 2008
1549 +** Am Campeon 1-12, 85579 Neubiberg, Germany
1550 +** Any use of this software is subject to the conclusion of a respective
1551 +** License agreement. Without such a License agreement no rights to the
1552 +** software are granted
1555 +** $Date $Author $Comment
1556 +** 24-03-2008 LXDB Initial version
1557 +** ============================================================================
1560 +#include <linux/module.h>
1561 +#include <linux/moduleparam.h>
1562 +#include <linux/types.h>
1563 +#include <linux/timer.h>
1564 +#include <linux/reboot.h>
1565 +#include <linux/init.h>
1566 +#include <linux/jiffies.h>
1568 +#include <falcon/vpe.h>
1570 +static unsigned long last_wdog_value;
1571 +static unsigned long vpe1_wdog_cleared;
1573 +static unsigned long vpe1_wdog_dead;
1574 +static void watchdog_vpe0_fire(unsigned long); /* Called when vpe0 timer expires */
1575 +static void keep_alive_vpe0(unsigned long);
1576 +VPE_SW_WDOG_RESET reset_local_fn;
1579 +static struct timer_list watchdog_vpe0_ticktock =
1580 + TIMER_INITIALIZER(watchdog_vpe0_fire, 0, 0);
1582 +static void watchdog_vpe0_fire (unsigned long flags)
1584 + volatile unsigned long *wdog_ctr_value;
1585 + wdog_ctr_value = (void*)vpe1_wdog_ctr;
1586 + if (*wdog_ctr_value == last_wdog_value) { /* VPE1 watchdog expiry handling */
1587 + vpe1_sw_wdog_stop(flags);
1589 + printk(KERN_DEBUG "VPE1 watchdog reset handler called\n");
1590 + /* Call the reset handler function */
1591 + reset_local_fn(flags);
1592 + } else { /* Everything is OK on vpe1 side. Continue. */
1593 + last_wdog_value = *wdog_ctr_value;
1594 + vpe1_wdog_cleared++;
1595 + keep_alive_vpe0(flags);
1599 +int32_t vpe1_sw_wdog_register_reset_handler (VPE_SW_WDOG_RESET reset_fn)
1601 + reset_local_fn = (VPE_SW_WDOG_RESET)reset_fn;
1605 +static void keep_alive_vpe0(unsigned long flags)
1607 + mod_timer(&watchdog_vpe0_ticktock, jiffies+ vpe1_wdog_timeout );
1610 +unsigned long vpe1_sw_wdog_start(unsigned long flags)
1612 + volatile unsigned long *wdog_ctr_value;
1613 + wdog_ctr_value = (void*)vpe1_wdog_ctr;
1614 + *wdog_ctr_value = 0;
1615 + last_wdog_value = 0;
1616 + keep_alive_vpe0(flags);
1620 +unsigned long vpe1_sw_wdog_stop(unsigned long flags)
1622 + del_timer(&watchdog_vpe0_ticktock);
1626 +static int __init watchdog_vpe1_init(void)
1628 + /* Nothing to be done here */
1632 +static void __exit watchdog_vpe1_exit(void)
1634 + unsigned long flags=0;
1635 + vpe1_sw_wdog_stop(flags);
1638 +module_init(watchdog_vpe1_init);
1639 +module_exit(watchdog_vpe1_exit);
1641 +EXPORT_SYMBOL(vpe1_sw_wdog_register_reset_handler);
1642 +EXPORT_SYMBOL(vpe1_sw_wdog_start);
1643 +EXPORT_SYMBOL(vpe1_sw_wdog_stop);
1645 +MODULE_AUTHOR("LXDB");
1646 +MODULE_DESCRIPTION("Software Watchdog For VPE1");
1647 +MODULE_LICENSE("GPL");
1649 +++ b/arch/mips/include/asm/mach-lantiq/falcon/vpe.h
1652 + * This program is free software; you can redistribute it and/or modify
1653 + * it under the terms of the GNU General Public License as published by
1654 + * the Free Software Foundation; either version 2 of the License, or
1655 + * (at your option) any later version.
1657 + * This program is distributed in the hope that it will be useful,
1658 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1659 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1660 + * GNU General Public License for more details.
1662 + * You should have received a copy of the GNU General Public License
1663 + * along with this program; if not, write to the Free Software
1664 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
1666 + * Copyright (C) 2005 infineon
1667 + * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
1670 +#ifndef _IFXMIPS_VPE_H__
1671 +#define _IFXMIPS_VPE_H__
1673 +/* For the explanation of the APIs please refer the section "MT APRP Kernel
1674 + * Programming" in AR9 SW Architecture Specification
1676 +int32_t vpe1_sw_start(void* sw_start_addr, uint32_t tcmask, uint32_t flags);
1677 +int32_t vpe1_sw_stop(uint32_t flags);
1678 +uint32_t vpe1_get_load_addr (uint32_t flags);
1679 +uint32_t vpe1_get_max_mem (uint32_t flags);
1681 +int32_t vpe1_set_boot_param(char *field, char *value, char flags);
1682 +int32_t vpe1_get_boot_param(char *field, char **value, char flags);
1684 +/* Watchdog APIs */
1685 +extern unsigned long vpe1_wdog_ctr;
1686 +extern unsigned long vpe1_wdog_timeout;
1688 +unsigned long vpe1_sw_wdog_start(unsigned long);
1689 +unsigned long vpe1_sw_wdog_stop(unsigned long);
1691 +typedef int (*VPE_SW_WDOG_RESET)(unsigned long wdog_cleared_ok_count);
1692 +int32_t vpe1_sw_wdog_register_reset_handler(VPE_SW_WDOG_RESET reset_fn);
1695 --- a/arch/mips/lantiq/Kconfig
1696 +++ b/arch/mips/lantiq/Kconfig
1699 select SOC_TYPE_XWAY
1706 source "arch/mips/lantiq/xway/Kconfig"
1707 +source "arch/mips/lantiq/falcon/Kconfig"
1710 --- a/arch/mips/lantiq/Makefile
1711 +++ b/arch/mips/lantiq/Makefile
1713 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
1715 obj-$(CONFIG_SOC_TYPE_XWAY) += xway/
1716 +obj-$(CONFIG_SOC_FALCON) += falcon/
1717 --- a/arch/mips/lantiq/Platform
1718 +++ b/arch/mips/lantiq/Platform
1720 cflags-$(CONFIG_LANTIQ) += -I$(srctree)/arch/mips/include/asm/mach-lantiq
1721 load-$(CONFIG_LANTIQ) = 0xffffffff80002000
1722 cflags-$(CONFIG_SOC_TYPE_XWAY) += -I$(srctree)/arch/mips/include/asm/mach-lantiq/xway
1723 +cflags-$(CONFIG_SOC_FALCON) += -I$(srctree)/arch/mips/include/asm/mach-lantiq/falcon
1724 --- a/arch/mips/lantiq/machtypes.h
1725 +++ b/arch/mips/lantiq/machtypes.h
1727 LTQ_MACH_GENERIC = 0,
1728 LTQ_MACH_EASY50712, /* Danube evaluation board */
1729 LTQ_MACH_EASY50601, /* Amazon SE evaluation board */
1732 + LANTIQ_MACH_EASY98000, /* Falcon Eval Board, NOR Flash */
1733 + LANTIQ_MACH_EASY98000SF, /* Falcon Eval Board, Serial Flash */
1734 + LANTIQ_MACH_EASY98020, /* Falcon Reference Board */