From 185ca444e3696eed9ccb01618a99584f76709f0f Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 28 Jun 2008 16:56:04 +0000 Subject: lots of ifxmips cleanups SVN-Revision: 11596 --- .../linux/ifxmips/files/drivers/char/ifxmips_led.c | 192 --------------------- .../ifxmips/files/drivers/leds/leds-ifxmips.c | 192 +++++++++++++++++++++ .../ifxmips/files/drivers/serial/ifxmips_asc.c | 83 ++++----- 3 files changed, 230 insertions(+), 237 deletions(-) delete mode 100644 target/linux/ifxmips/files/drivers/char/ifxmips_led.c create mode 100644 target/linux/ifxmips/files/drivers/leds/leds-ifxmips.c (limited to 'target/linux/ifxmips/files/drivers') diff --git a/target/linux/ifxmips/files/drivers/char/ifxmips_led.c b/target/linux/ifxmips/files/drivers/char/ifxmips_led.c deleted file mode 100644 index 090516c5ad..0000000000 --- a/target/linux/ifxmips/files/drivers/char/ifxmips_led.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - * - * Copyright (C) 2006 infineon - * Copyright (C) 2007 John Crispin - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DRVNAME "ifxmips_led" - -#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_FALLING -//#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_RISING - -#define IFXMIPS_LED_SPEED IFXMIPS_LED_8HZ - -#define IFXMIPS_LED_GPIO_PORT 0 - -#define IFXMIPS_MAX_LED 24 - -struct ifxmips_led { - struct led_classdev cdev; - u8 bit; -}; - -void -ifxmips_led_set (unsigned int led) -{ - led &= 0xffffff; - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CPU0) | led, IFXMIPS_LED_CPU0); -} -EXPORT_SYMBOL(ifxmips_led_set); - -void -ifxmips_led_clear (unsigned int led) -{ - led = ~(led & 0xffffff); - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CPU0) & led, IFXMIPS_LED_CPU0); -} -EXPORT_SYMBOL(ifxmips_led_clear); - -void -ifxmips_led_blink_set (unsigned int led) -{ - led &= 0xffffff; - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | led, IFXMIPS_LED_CON0); -} -EXPORT_SYMBOL(ifxmips_led_blink_set); - -void -ifxmips_led_blink_clear (unsigned int led) -{ - led = ~(led & 0xffffff); - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & led, IFXMIPS_LED_CON0); -} -EXPORT_SYMBOL(ifxmips_led_blink_clear); - -void -ifxmips_ledapi_set(struct led_classdev *led_cdev, enum led_brightness value) -{ - struct ifxmips_led *led_dev = container_of(led_cdev, struct ifxmips_led, cdev); - - if(value) - ifxmips_led_set(1 << led_dev->bit); - else - ifxmips_led_clear(1 << led_dev->bit); -} - -void -ifxmips_led_setup_gpio (void) -{ - int i = 0; - - /* we need to setup pins SH,D,ST (4,5,6) */ - for (i = 4; i < 7; i++) - { - ifxmips_port_set_altsel0(IFXMIPS_LED_GPIO_PORT, i); - ifxmips_port_clear_altsel1(IFXMIPS_LED_GPIO_PORT, i); - ifxmips_port_set_dir_out(IFXMIPS_LED_GPIO_PORT, i); - ifxmips_port_set_open_drain(IFXMIPS_LED_GPIO_PORT, i); - } -} - -static int -ifxmips_led_probe(struct platform_device *dev) -{ - int i = 0; - - ifxmips_led_setup_gpio(); - - ifxmips_w32(0, IFXMIPS_LED_AR); - ifxmips_w32(0, IFXMIPS_LED_CPU0); - ifxmips_w32(0, IFXMIPS_LED_CPU1); - ifxmips_w32(LED_CON0_SWU, IFXMIPS_LED_CON0); - ifxmips_w32(0, IFXMIPS_LED_CON1); - - /* setup the clock edge that the shift register is triggered on */ - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & ~IFXMIPS_LED_EDGE_MASK, IFXMIPS_LED_CON0); - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | IFXMIPS_LED_CLK_EDGE, IFXMIPS_LED_CON0); - - /* per default leds 15-0 are set */ - ifxmips_w32(IFXMIPS_LED_GROUP1 | IFXMIPS_LED_GROUP0, IFXMIPS_LED_CON1); - - /* leds are update periodically by the FPID */ - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) & ~IFXMIPS_LED_UPD_MASK, IFXMIPS_LED_CON1); - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) | IFXMIPS_LED_UPD_SRC_FPI, IFXMIPS_LED_CON1); - - /* set led update speed */ - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) & ~IFXMIPS_LED_MASK, IFXMIPS_LED_CON1); - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) | IFXMIPS_LED_SPEED, IFXMIPS_LED_CON1); - - /* adsl 0 and 1 leds are updated by the arc */ - ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | IFXMIPS_LED_ADSL_SRC, IFXMIPS_LED_CON0); - - /* per default, the leds are turned on */ - ifxmips_pmu_enable(IFXMIPS_PMU_PWDCR_LED); - - for(i = 0; i < IFXMIPS_MAX_LED; i++) - { - struct ifxmips_led *tmp = kzalloc(sizeof(struct ifxmips_led), GFP_KERNEL); - tmp->cdev.brightness_set = ifxmips_ledapi_set; - tmp->cdev.name = kmalloc(sizeof("ifxmips:led:00"), GFP_KERNEL); - sprintf((char*)tmp->cdev.name, "ifxmips:led:%02d", i); - tmp->cdev.default_trigger = NULL; - tmp->bit = i; - led_classdev_register(&dev->dev, &tmp->cdev); - } - - return 0; -} - -static int -ifxmips_led_remove(struct platform_device *pdev) -{ - return 0; -} - -static struct -platform_driver ifxmips_led_driver = { - .probe = ifxmips_led_probe, - .remove = ifxmips_led_remove, - .driver = { - .name = DRVNAME, - .owner = THIS_MODULE, - }, -}; - -int __init -ifxmips_led_init (void) -{ - int ret = platform_driver_register(&ifxmips_led_driver); - if (ret) - printk(KERN_INFO "ifxmips_led: Error registering platfom driver!"); - - return ret; -} - -void __exit -ifxmips_led_exit (void) -{ - platform_driver_unregister(&ifxmips_led_driver); -} - -module_init(ifxmips_led_init); -module_exit(ifxmips_led_exit); diff --git a/target/linux/ifxmips/files/drivers/leds/leds-ifxmips.c b/target/linux/ifxmips/files/drivers/leds/leds-ifxmips.c new file mode 100644 index 0000000000..090516c5ad --- /dev/null +++ b/target/linux/ifxmips/files/drivers/leds/leds-ifxmips.c @@ -0,0 +1,192 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + * + * Copyright (C) 2006 infineon + * Copyright (C) 2007 John Crispin + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRVNAME "ifxmips_led" + +#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_FALLING +//#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_RISING + +#define IFXMIPS_LED_SPEED IFXMIPS_LED_8HZ + +#define IFXMIPS_LED_GPIO_PORT 0 + +#define IFXMIPS_MAX_LED 24 + +struct ifxmips_led { + struct led_classdev cdev; + u8 bit; +}; + +void +ifxmips_led_set (unsigned int led) +{ + led &= 0xffffff; + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CPU0) | led, IFXMIPS_LED_CPU0); +} +EXPORT_SYMBOL(ifxmips_led_set); + +void +ifxmips_led_clear (unsigned int led) +{ + led = ~(led & 0xffffff); + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CPU0) & led, IFXMIPS_LED_CPU0); +} +EXPORT_SYMBOL(ifxmips_led_clear); + +void +ifxmips_led_blink_set (unsigned int led) +{ + led &= 0xffffff; + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | led, IFXMIPS_LED_CON0); +} +EXPORT_SYMBOL(ifxmips_led_blink_set); + +void +ifxmips_led_blink_clear (unsigned int led) +{ + led = ~(led & 0xffffff); + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & led, IFXMIPS_LED_CON0); +} +EXPORT_SYMBOL(ifxmips_led_blink_clear); + +void +ifxmips_ledapi_set(struct led_classdev *led_cdev, enum led_brightness value) +{ + struct ifxmips_led *led_dev = container_of(led_cdev, struct ifxmips_led, cdev); + + if(value) + ifxmips_led_set(1 << led_dev->bit); + else + ifxmips_led_clear(1 << led_dev->bit); +} + +void +ifxmips_led_setup_gpio (void) +{ + int i = 0; + + /* we need to setup pins SH,D,ST (4,5,6) */ + for (i = 4; i < 7; i++) + { + ifxmips_port_set_altsel0(IFXMIPS_LED_GPIO_PORT, i); + ifxmips_port_clear_altsel1(IFXMIPS_LED_GPIO_PORT, i); + ifxmips_port_set_dir_out(IFXMIPS_LED_GPIO_PORT, i); + ifxmips_port_set_open_drain(IFXMIPS_LED_GPIO_PORT, i); + } +} + +static int +ifxmips_led_probe(struct platform_device *dev) +{ + int i = 0; + + ifxmips_led_setup_gpio(); + + ifxmips_w32(0, IFXMIPS_LED_AR); + ifxmips_w32(0, IFXMIPS_LED_CPU0); + ifxmips_w32(0, IFXMIPS_LED_CPU1); + ifxmips_w32(LED_CON0_SWU, IFXMIPS_LED_CON0); + ifxmips_w32(0, IFXMIPS_LED_CON1); + + /* setup the clock edge that the shift register is triggered on */ + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & ~IFXMIPS_LED_EDGE_MASK, IFXMIPS_LED_CON0); + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | IFXMIPS_LED_CLK_EDGE, IFXMIPS_LED_CON0); + + /* per default leds 15-0 are set */ + ifxmips_w32(IFXMIPS_LED_GROUP1 | IFXMIPS_LED_GROUP0, IFXMIPS_LED_CON1); + + /* leds are update periodically by the FPID */ + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) & ~IFXMIPS_LED_UPD_MASK, IFXMIPS_LED_CON1); + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) | IFXMIPS_LED_UPD_SRC_FPI, IFXMIPS_LED_CON1); + + /* set led update speed */ + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) & ~IFXMIPS_LED_MASK, IFXMIPS_LED_CON1); + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) | IFXMIPS_LED_SPEED, IFXMIPS_LED_CON1); + + /* adsl 0 and 1 leds are updated by the arc */ + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | IFXMIPS_LED_ADSL_SRC, IFXMIPS_LED_CON0); + + /* per default, the leds are turned on */ + ifxmips_pmu_enable(IFXMIPS_PMU_PWDCR_LED); + + for(i = 0; i < IFXMIPS_MAX_LED; i++) + { + struct ifxmips_led *tmp = kzalloc(sizeof(struct ifxmips_led), GFP_KERNEL); + tmp->cdev.brightness_set = ifxmips_ledapi_set; + tmp->cdev.name = kmalloc(sizeof("ifxmips:led:00"), GFP_KERNEL); + sprintf((char*)tmp->cdev.name, "ifxmips:led:%02d", i); + tmp->cdev.default_trigger = NULL; + tmp->bit = i; + led_classdev_register(&dev->dev, &tmp->cdev); + } + + return 0; +} + +static int +ifxmips_led_remove(struct platform_device *pdev) +{ + return 0; +} + +static struct +platform_driver ifxmips_led_driver = { + .probe = ifxmips_led_probe, + .remove = ifxmips_led_remove, + .driver = { + .name = DRVNAME, + .owner = THIS_MODULE, + }, +}; + +int __init +ifxmips_led_init (void) +{ + int ret = platform_driver_register(&ifxmips_led_driver); + if (ret) + printk(KERN_INFO "ifxmips_led: Error registering platfom driver!"); + + return ret; +} + +void __exit +ifxmips_led_exit (void) +{ + platform_driver_unregister(&ifxmips_led_driver); +} + +module_init(ifxmips_led_init); +module_exit(ifxmips_led_exit); diff --git a/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c b/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c index 63a4c2af9e..17d933c20b 100644 --- a/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c +++ b/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c @@ -41,7 +41,7 @@ #include #include #include - +#include #include #include #include @@ -60,7 +60,6 @@ static void ifxmipsasc_tx_chars(struct uart_port *port); extern void prom_printf(const char * fmt, ...); static struct uart_port ifxmipsasc_port[2]; static struct uart_driver ifxmipsasc_reg; -static unsigned int uartclk = 0; extern unsigned int ifxmips_get_fpi_hz(void); static void @@ -155,7 +154,6 @@ static void ifxmipsasc_tx_chars(struct uart_port *port) { struct circ_buf *xmit = &port->info->xmit; - if(uart_tx_stopped(port)) { ifxmipsasc_stop_tx(port); @@ -245,10 +243,7 @@ ifxmipsasc_startup(struct uart_port *port) unsigned long flags; int retval; - if(uartclk == 0) - uartclk = ifxmips_get_fpi_hz(); - - port->uartclk = uartclk; + port->uartclk = ifxmips_get_fpi_hz(); ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CLC) & ~IFXMIPS_ASC_CLC_DISS, port->membase + IFXMIPS_ASC_CLC); ifxmips_w32(((ifxmips_r32(port->membase + IFXMIPS_ASC_CLC) & ~ASCCLC_RMCMASK)) | (1 << ASCCLC_RMCOFFSET), port->membase + IFXMIPS_ASC_CLC); @@ -260,17 +255,17 @@ ifxmipsasc_startup(struct uart_port *port) local_irq_save(flags); - retval = request_irq(port->irq, ifxmipsasc_rx_int, IRQF_DISABLED, "asc_rx", port); + retval = request_irq(port->irq, ifxmipsasc_tx_int, IRQF_DISABLED, "asc_tx", port); if(retval) { - printk("failed to request ifxmipsasc_rx_int\n"); + printk("failed to request ifxmipsasc_tx_int\n"); return retval; } - retval = request_irq(port->irq + 2, ifxmipsasc_tx_int, IRQF_DISABLED, "asc_tx", port); + retval = request_irq(port->irq + 2, ifxmipsasc_rx_int, IRQF_DISABLED, "asc_rx", port); if(retval) { - printk("failed to request ifxmipsasc_tx_int\n"); + printk("failed to request ifxmipsasc_rx_int\n"); goto err1; } @@ -402,7 +397,15 @@ static void ifxmipsasc_set_termios(struct uart_port *port, struct ktermios *new, static const char* ifxmipsasc_type(struct uart_port *port) { - return port->type == PORT_IFXMIPSASC ? "IFXMIPSASC" : NULL; + if(port->type == PORT_IFXMIPSASC) + { + if(port->membase == IFXMIPS_ASC_BASE_ADDR) + return "asc0"; + else + return "asc1"; + } else { + return NULL; + } } static void @@ -465,54 +468,53 @@ static struct uart_port ifxmipsasc_port[2] = membase: (void *)IFXMIPS_ASC_BASE_ADDR, mapbase: IFXMIPS_ASC_BASE_ADDR, iotype: SERIAL_IO_MEM, - irq: IFXMIPSASC_RIR(0), + irq: IFXMIPSASC_TIR(0), uartclk: 0, fifosize: 16, type: PORT_IFXMIPSASC, ops: &ifxmipsasc_pops, flags: ASYNC_BOOT_AUTOCONF, + line: 0 }, { membase: (void *)(IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF), mapbase: IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF, iotype: SERIAL_IO_MEM, - irq: IFXMIPSASC_RIR(1), + irq: IFXMIPSASC_TIR(1), uartclk: 0, fifosize: 16, type: PORT_IFXMIPSASC, ops: &ifxmipsasc_pops, flags: ASYNC_BOOT_AUTOCONF, + line: 1 } }; static void ifxmipsasc_console_write(struct console *co, const char *s, u_int count) { + int port = co->index; int i, fifocnt; unsigned long flags; - local_irq_save(flags); for(i = 0; i < count; i++) { - /* wait until the FIFO is not full */ - do - { - fifocnt = (ifxmips_r32((u32*)(IFXMIPS_ASC_BASE_ADDR + (co->index * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK) + do { + fifocnt = (ifxmips_r32((u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK) >> ASCFSTAT_TXFFLOFF; - }while(fifocnt == IFXMIPSASC_TXFIFO_FULL); + } while(fifocnt == IFXMIPSASC_TXFIFO_FULL); if(s[i] == '\0') break; if(s[i] == '\n') { - ifxmips_w32('\r', (u32*)(IFXMIPS_ASC_BASE_ADDR + (co->index * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF)); - do - { - fifocnt = (ifxmips_r32((u32*)(IFXMIPS_ASC_BASE_ADDR + (co->index * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK) + ifxmips_w32('\r', (u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF)); + do { + fifocnt = (ifxmips_r32((u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK) >> ASCFSTAT_TXFFLOFF; } while(fifocnt == IFXMIPSASC_TXFIFO_FULL); } - ifxmips_w32(s[i], (u32*)(IFXMIPS_ASC_BASE_ADDR + (co->index * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF)); + ifxmips_w32(s[i], (u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF)); } local_irq_restore(flags); @@ -521,23 +523,16 @@ ifxmipsasc_console_write(struct console *co, const char *s, u_int count) static int __init ifxmipsasc_console_setup(struct console *co, char *options) { - struct uart_port *port; + int port = co->index; int baud = 115200; int bits = 8; int parity = 'n'; int flow = 'n'; - - if(uartclk == 0) - uartclk = ifxmips_get_fpi_hz(); - co->index = 0; - port = &ifxmipsasc_port[co->index]; - ifxmipsasc_port[co->index].uartclk = uartclk; - ifxmipsasc_port[co->index].type = PORT_IFXMIPSASC; - + ifxmipsasc_port[port].uartclk = ifxmips_get_fpi_hz(); + ifxmipsasc_port[port].type = PORT_IFXMIPSASC; if(options) uart_parse_options(options, &baud, &parity, &bits, &flow); - - return uart_set_options(port, co, baud, parity, bits, flow); + return uart_set_options(&ifxmipsasc_port[port], co, baud, parity, bits, flow); } static struct console ifxmipsasc_console[2] = @@ -578,22 +573,20 @@ static struct uart_driver ifxmipsasc_reg = .major = TTY_MAJOR, .minor = 64, .nr = 2, - .cons = ifxmipsasc_console, + .cons = &ifxmipsasc_console[1], }; -static int __init +int __init ifxmipsasc_init(void) { - unsigned char res; - + int ret; uart_register_driver(&ifxmipsasc_reg); - res = uart_add_one_port(&ifxmipsasc_reg, &ifxmipsasc_port[0]); - res = uart_add_one_port(&ifxmipsasc_reg, &ifxmipsasc_port[1]); - - return res; + ret = uart_add_one_port(&ifxmipsasc_reg, &ifxmipsasc_port[0]); + ret = uart_add_one_port(&ifxmipsasc_reg, &ifxmipsasc_port[1]); + return 0; } -static void __exit +void __exit ifxmipsasc_exit(void) { uart_unregister_driver(&ifxmipsasc_reg); -- cgit v1.2.3