Ignore:
Timestamp:
Jul 7, 2006, 12:14:16 AM (19 years ago)
Author:
Waldemar Brodkorb <wbx@…>
Branches:
freewrt_1_0, freewrt_2_0
Children:
dfb8263
Parents:
b232ea4
Message:

use OpenWrt whiterussian system code and wireless driver

  • make it build with 2.4.32
  • add netgear wgt634u patches (untested)
  • keep newest flash map stuff
  • add wlcompat and wl.o from whiterussian
  • add diag_led.c from whiterussian

git-svn-id: svn://www.freewrt.org/trunk/freewrt@177 afb5a338-a214-0410-bd46-81f09a774fd1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • target/linux/package/diag/diag_led.c

    rb232ea4 r2268d20  
    22 * diag_led.c - replacement diag module
    33 *
    4  * Copyright (C) 2004 Mike Baker,
    5  *                    Imre Kaloz <kaloz@dune.hu>
     4 * Copyright (C) 2004-2006 Mike Baker,
     5 *                         Imre Kaloz <kaloz@dune.hu>,
     6 *                         Felix Fietkau <nbd@openwrt.org>
    67 *
    78 * This program is free software; you can redistribute it and/or
     
    1920 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    2021 *
    21  * $Id: diag_led.c 3510 2006-03-27 21:05:17Z wbx $
     22 * $Id: 005-diag_led.patch 3355 2006-03-13 07:57:51Z nbd $
    2223 */
    2324
     
    2930 * 2005/04/13 added licensing informations
    3031 * 2005/04/18 base reset polarity off initial readings
    31  * 2006/02/07 motorola wa840g/we800g support added
    3232 */
    3333
     
    3838#include <asm/io.h>
    3939#include <typedefs.h>
    40 #include <osl.h>
    4140#include <bcmdevs.h>
    4241#include <sbutils.h>
     
    4645
    4746// v2.x - - - - -
     47#define BITS(n)                 ((1 << n) - 1)
     48#define ISSET(n,b)              ((n & (1 << b)) ? 1 : 0)
    4849#define DIAG_GPIO (1<<1)
     50#define AOSS_GPIO (1<<6)
    4951#define DMZ_GPIO  (1<<7)
     52#define SES_GPIO  ((1 << 2) | (1 << 3) | (1 << 5))
    5053
    5154static void set_gpio(uint32 mask, uint32 value) {
    52         sb_gpiocontrol(sbh,mask, 0, GPIO_DRV_PRIORITY);
    53         sb_gpioouten(sbh,mask,mask,GPIO_DRV_PRIORITY);
    54         sb_gpioout(sbh,mask,value,GPIO_DRV_PRIORITY);
     55        sb_gpiocontrol(sbh,mask,0);
     56        sb_gpioouten(sbh,mask,mask);
     57        sb_gpioout(sbh,mask,value);
    5558}
    5659
     
    6063static void v2_set_dmz(u8 state) {
    6164        set_gpio(DMZ_GPIO,state);
     65}
     66static void v2_set_aoss(u8 state) {
     67        set_gpio(AOSS_GPIO,state);
     68}
     69static void v2_set_ses(u8 state) {
     70        set_gpio(SES_GPIO, (ISSET(state, 0) << 2) | (ISSET(state, 1) << 3) | (ISSET(state, 2) << 5));
    6271}
    6372
     
    8190}
    8291
    83 static void wap1_set_diag(u8 state) {
    84        set_gpio(1<<3,state);
    85 }
    86 static void wap1_set_dmz(u8 state) {
    87        set_gpio(1<<4,state);
    88 }
    89 
    9092// - - - - -
    9193static void ignore(u8 ignored) {};
    9294
    9395// - - - - -
    94 #define BIT_DMZ         0x01
    95 #define BIT_DIAG        0x04
     96#define BIT_DMZ         (1 << 0)
     97#define BIT_DIAG        (1 << 2)
     98#define BIT_SES         (BITS(3) << 3)
    9699
    97100void (*set_diag)(u8 state);
    98101void (*set_dmz)(u8 state);
    99 
     102void (*set_ses)(u8 state);
     103
     104static unsigned int diag_reverse = 1;
     105static unsigned int ses_reverse = 1;
    100106static unsigned int diag = 0;
    101107
    102108static void diag_change()
    103109{
    104         set_diag(0xFF); // off
    105         set_dmz(0xFF); // off
     110        set_diag(diag_reverse ? 0xFF : 0x00); // off
     111        set_dmz(diag_reverse ? 0xFF : 0x00); // off
     112        set_ses(ses_reverse ? 0xFF : 0x00); // off
    106113
    107114        if(diag & BIT_DIAG)
    108                 set_diag(0x00); // on
     115                set_diag(diag_reverse ? 0x00 : 0xFF); // on
    109116        if(diag & BIT_DMZ)
    110                 set_dmz(0x00); // on
     117                set_dmz(diag_reverse ? 0x00 : 0xFF); // on
     118        if(diag & BIT_SES)
     119                set_ses(((ses_reverse ? ~diag : diag) >> 3) & BITS(3));
    111120}
    112121
     
    126135static unsigned char reset_polarity = 0;
    127136static unsigned int reset = 0;
     137static unsigned char button_gpio = 0;
     138static unsigned char button_polarity = 0;
     139static unsigned int button = 0;
     140
     141
     142static int read_gpio(int gpio, int polarity)
     143{
     144        int res;
     145       
     146        if (gpio) {
     147                sb_gpiocontrol(sbh,gpio,gpio);
     148                sb_gpioouten(sbh,gpio,0);
     149                res=!(sb_gpioin(sbh)&gpio);
     150
     151                return (polarity ? !res : res);
     152        }
     153
     154        return 0;
     155}
    128156
    129157static int proc_reset(ctl_table *table, int write, struct file *filp,
    130158                void *buffer, size_t *lenp)
    131159{
    132 
    133         if (reset_gpio) {
    134                 sb_gpiocontrol(sbh,reset_gpio,reset_gpio,GPIO_DRV_PRIORITY);
    135                 sb_gpioouten(sbh,reset_gpio,0,GPIO_DRV_PRIORITY);
    136                 reset=!(sb_gpioin(sbh)&reset_gpio);
    137 
    138                 if (reset_polarity) reset=!reset;
    139         } else {
    140                 reset=0;
    141         }
     160        reset = read_gpio(reset_gpio, reset_polarity);
     161
     162        return proc_dointvec(table, write, filp, buffer, lenp);
     163}
     164
     165static int proc_button(ctl_table *table, int write, struct file *filp,
     166                void *buffer, size_t *lenp)
     167{
     168        button = read_gpio(button_gpio, button_polarity);
    142169
    143170        return proc_dointvec(table, write, filp, buffer, lenp);
     
    164191           proc_handler: proc_reset
    165192         },
     193         {
     194           ctl_name: 2002,
     195           procname: "button",
     196           data: &button,
     197           maxlen: sizeof(button),
     198           mode: 0444,
     199           proc_handler: proc_button
     200         },
    166201         { 0 }
    167202};
     
    179214        set_diag=ignore;
    180215        set_dmz=ignore;
     216        set_ses=ignore;
    181217       
    182218        buf=nvram_get("pmon_ver") ?: "";
    183219        if (((board_type & 0xf00) == 0x400) && (strncmp(buf, "CFE", 3) != 0)) {
    184220                buf=nvram_get("boardtype")?:"";
    185                 if (!strncmp(buf,"bcm94710dev",11)) {
     221                if (!strcmp(buf,"bcm94710dev")) {
    186222                        buf=nvram_get("boardnum")?:"";
    187223                        if (!strcmp(buf,"42")) {
     
    191227                                reset_gpio=(1<<6);
    192228                        }
    193                         if (simple_strtoul(buf, NULL, 0) == 2) {
    194                                 // wap54g v1.0
    195                                 // do not use strcmp as PMON v5.3.22 has some built-in nvram
    196                                 // defaults with trailing \r
    197                                 set_diag=wap1_set_diag;
    198                                 // no dmz led on wap54g, used green led
    199                                 // labeled "WLAN Link" instead
    200                                 set_dmz=wap1_set_dmz;
    201                                 reset_gpio=(1<<0);
    202                         }
    203229                        if (!strcmp(buf,"asusX")) {
    204230                                //asus wl-500g
    205231                                reset_gpio=(1<<6);
    206                         }
    207                         if (!strcmp(buf,"2")) {
    208                                 //wa840g v1 / we800g v1
    209                                 reset_gpio=(1<<0);
    210232                        }
    211233                }
     
    229251                        set_diag=v2_set_diag;
    230252                        set_dmz=v2_set_dmz;
     253                        set_ses=v2_set_ses;
     254                       
    231255                        reset_gpio=(1<<6);
     256                        button_gpio=(1<<4);
     257
     258                        if (!strcmp((nvram_get("boardtype")?:""), "0x0101")) // WRT54G3G
     259                                ses_reverse = 0;
     260                        else
     261                                ses_reverse = 1;
    232262                }
    233263                if (!strcmp(buf,"44")) {
     
    237267                if (!strcmp(buf,"00")) {
    238268                        //buffalo
     269                        diag_reverse = 0;
     270                        set_dmz=v2_set_diag;
     271                        set_diag=v2_set_aoss;
    239272                        reset_gpio=(1<<7);
    240273                }
     
    245278        }
    246279
    247        
    248         sb_gpiocontrol(sbh,reset_gpio,reset_gpio,GPIO_DRV_PRIORITY);
    249         sb_gpioouten(sbh,reset_gpio,0,GPIO_DRV_PRIORITY);
     280        sb_gpiocontrol(sbh,reset_gpio,reset_gpio);
     281        sb_gpioouten(sbh,reset_gpio,0);
    250282        reset_polarity=!(sb_gpioin(sbh)&reset_gpio);
     283
     284        if (button_gpio) {
     285                sb_gpiocontrol(sbh,button_gpio,button_gpio);
     286                sb_gpioouten(sbh,button_gpio,0);
     287                button_polarity=!(sb_gpioin(sbh)&button_gpio);
     288        } else {
     289                // don't create /proc/button
     290                sys_diag[2].ctl_name = 0;
     291        }
    251292
    252293        diag_sysctl_header = register_sysctl_table(sys_diag, 0);
Note: See TracChangeset for help on using the changeset viewer.