static int __init gpio_init(void) { int i; if (!(gpio_sih = si_kattach(SI_OSH))) return -ENODEV; si_gpiosetcore(gpio_sih); if ((gpio_major = devfs_register_chrdev(0, "gpio", &gpio_fops)) < 0) return gpio_major; gpio_dir = devfs_mk_dir(NULL, "gpio", NULL); for (i = 0; i < ARRAYSIZE(gpio_file); i++) { gpio_file[i].handle = devfs_register(gpio_dir, gpio_file[i].name, DEVFS_FL_DEFAULT, gpio_major, i, S_IFCHR | S_IRUGO | S_IWUGO, &gpio_fops, NULL); } return 0; }
static int gen_gpio_init(void) { if (!(gpio_sih = si_kattach(SI_OSH))) { DBG("%s: si_kattach failed\n", __FUNCTION__); return -ENODEV; } si_gpiosetcore(gpio_sih); return 0; }
/* Enable register access to the chip */ static void adm_enable(adm_info_t *adm) { void *regs; /* Save current core index */ adm->coreidx = si_coreidx(adm->sih); /* Switch to GPIO core for faster access */ regs = si_gpiosetcore(adm->sih); ASSERT(regs); }
/********************************************************************************************** * Functions visible to this file only ******************************************************************************************** */ static int bcmgpio_drvinit () { #if defined(__ECOS) if (!(gpio_sih = (void *)si_kattach(SI_OSH))) return -1; bcmgpio_fd = 1; si_gpiosetcore(gpio_sih); return 0; #else bcmgpio_fd = open("/dev/gpio", O_RDWR); if (bcmgpio_fd == -1) { GPIO_ERROR ("Failed to open /dev/gpio\n"); return -1; } return 0; #endif }
static int __init gpio_init(void) { int i; if (!(gpio_sih = si_kattach(SI_OSH))) return -ENODEV; si_gpiosetcore(gpio_sih); if ((gpio_major = register_chrdev(127, "gpio", &gpio_fops)) < 0) { return gpio_major; } // devfs_mk_cdev(MKDEV(gpio_major, 0), S_IFCHR | S_IRUGO | S_IWUGO, "gpio"); // devfs_mk_dir("gpio"); gpio_class = class_create(THIS_MODULE, "gpio"); for (i = 0; i < ARRAYSIZE(gpio_file); i++) { // register_chrdev(MKDEV(127, i), gpio_file[i].name, &gpio_fops); class_device_create(gpio_class, NULL, MKDEV(127, i), NULL, gpio_file[i].name); // printk("gpio dev %d created\n",dev); // devfs_mk_cdev(MKDEV(127, i), S_IFCHR | S_IRUGO | S_IWUGO, gpio_file[i].name); } gpio_init_flag=1; int gpios = 0; if (iswrt350n) { printk(KERN_EMERG "WRT350N GPIO Init\n"); /* For WRT350N USB LED control */ si_gpioreserve(gpio_sih, 0x400, GPIO_HI_PRIORITY); si_gpioouten(gpio_sih, 0x400, 0x400, GPIO_HI_PRIORITY); si_gpioreserve(gpio_sih, 0x800, GPIO_HI_PRIORITY); si_gpioouten(gpio_sih, 0x800, 0x800, GPIO_HI_PRIORITY); //if (nvram_match("disabled_5397", "1")) { // printk("5397 switch GPIO-Reset \n"); //} USB_SET_LED(USB_DISCONNECT); //2005-02-24 by kanki for USB LED } if (iswrt350n) { si_gpioreserve(gpio_sih, 0x4, GPIO_HI_PRIORITY); si_gpioouten(gpio_sih, 0x4, 0x4, GPIO_HI_PRIORITY); si_gpioout(gpio_sih, 0x4, 0x4, GPIO_HI_PRIORITY); } uint boardnum = bcm_strtoul( nvram_safe_get( "boardnum" ), NULL, 0 ); gpios = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 | 1<<9 | 1<<10 | 1<<11; if ((boardnum == 1 || boardnum == 3500) && nvram_match("boardtype", "0x04CF") && (nvram_match("boardrev", "0x1213") || nvram_match("boardrev", "02"))) { printk(KERN_EMERG "WNR3500V2 GPIO Init\n"); gpios = 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7; } if ((boardnum == 42 || boardnum == 66) && nvram_match("boardtype", "0x04EF") && (nvram_match("boardrev", "0x1304") || nvram_match("boardrev", "0x1305") || nvram_match("boardrev", "0x1307"))) { printk(KERN_EMERG "WRT320N/E2000 GPIO Init\n"); gpios = 1 << 2 | 1 << 3 | 1 << 4; } if (boardnum == 42 && ((nvram_match("boot_hw_model", "WRT160N") && nvram_match("boot_hw_ver", "3.0")) || (nvram_match("boot_hw_model", "M10") && nvram_match("boot_hw_ver", "1.0")) || (nvram_match("boot_hw_model", "E100") && nvram_match("boot_hw_ver", "1.0")) ) ) { printk(KERN_EMERG "WRT160Nv3/M10/E1000 GPIO Init\n"); gpios = 1 << 1 | 1 << 2 | 1 << 4; } if (boardnum == 42 && ((nvram_match("boot_hw_model", "WRT310N") && nvram_match("boot_hw_ver", "2.0")) || (nvram_match("boot_hw_model", "M20") && nvram_match("boot_hw_ver", "1.0")) ) ) { printk(KERN_EMERG "WRT310Nv2/M20 GPIO Init\n"); gpios = 1 << 1 | 1 << 2 | 1 << 4; } if (nvram_match("boardnum", "00") && nvram_match("boardrev", "0x11") && nvram_match("boardtype", "0x048e") && (nvram_match("melco_id", "32093") || nvram_match("melco_id", "32064"))) { printk(KERN_EMERG "WHR-G125 / WHR-HP-G125 GPIO Init\n"); gpios = 1 << 1 | 1 << 6 | 1 << 7; } if (nvram_match("boardnum", "00") && nvram_match("boardrev", "0x13") && nvram_match("boardtype", "0x467")) { printk(KERN_EMERG "WHR-G54S / WHR-HP-G54 GPIO Init\n"); gpios = 1 << 1 | 1 << 6 | 1 << 7; } if (nvram_match("boardtype", "0x04cf") && (nvram_match("boot_hw_model", "WRT610N") || nvram_match("boot_hw_model", "E300"))) { printk(KERN_EMERG "WRT610Nv2/E3000 GPIO Init\n"); gpios = 1 << 0 | 1 << 3 | 1 << 5 | 1 << 7; } if (boardnum == 42 && nvram_match("boardrev", "0x10") && (nvram_match("boardtype", "0x0467") || nvram_match("boardtype", "0x0708") || nvram_match("boardtype", "0x0101"))) { printk(KERN_EMERG "WRT54G/GS/GL/TM GPIO Init\n"); gpios = 1 << 1 | 1 << 2 | 1 << 3 | 1 << 4 | 1 << 7; } if (boardnum == 45 && nvram_match("boardrev", "0x1402") && nvram_match("boardtype", "0x04EC")) { printk(KERN_EMERG "RT-N10 GPIO Init\n"); gpios = 1 << 1; } if (boardnum == 45 && nvram_match("boardrev", "0x1102") && nvram_match("boardtype", "0x0550")) { printk(KERN_EMERG "RT-N10U GPIO Init\n"); gpios = 1 << 5; } if (boardnum == 45 && nvram_match("boardrev", "0x1153") && nvram_match("boardtype", "0x058e")) { printk(KERN_EMERG "RT-N10+ D1 GPIO INIT\n"); gpios = 1 << 6 | 1 << 7 | 1 << 21 | 1 << 20; } if (boardnum == 1 && nvram_match("boardtype", "0xE4CD") && nvram_match("boardrev", "0x1700")) { printk(KERN_EMERG "WNR2000v2 GPIO Init\n"); gpios = 1 << 2 | 1 << 6 | 1 << 7 | 1 << 8; } if (boardnum == 45 && nvram_match("boardrev", "0x1201") && nvram_match("boardtype", "0x04CD")) { printk(KERN_EMERG "RT-N12 GPIO Init\n"); gpios = 1 << 0 | 1 << 2; } if (boardnum == 45 && nvram_match("boardrev", "0x1218") && nvram_match("boardtype", "0x04cf")) { printk(KERN_EMERG "RT-N16 GPIO Init\n"); gpios = 1 << 1; } if (boardnum == 1 && nvram_match("boardrev", "0x23") && nvram_match("boardtype", "0x0472")) { if (nvram_match("cardbus", "1")) { printk(KERN_EMERG "WNR324v2 GPIO Init\n"); gpios = 1 << 2 | 1 << 3 | 1 << 7; } else { printk(KERN_EMERG "WNDR3300 GPIO Init\n"); gpios = 1 << 5 | 1 << 7; } } if (nvram_match("boardnum", "00") && nvram_match("boardtype", "0x0101") && nvram_match("boardrev", "0x10")) { printk(KERN_EMERG "WBR2-G54(S) GPIO Init\n"); gpios = 1 << 1 | 1 << 6; } if (nvram_match("boardtype", "0xd4cf") && nvram_match("boardrev", "0x1204")) { printk(KERN_EMERG "F7D4301v1 GPIO Init\n"); gpios = 1 << 10 | 1 << 11 | 1 << 13; } if (nvram_match("boardtype", "0xa4cf") && (nvram_match("boardrev", "0x1100") || nvram_match("boardrev", "0x1102"))) { printk(KERN_EMERG "F7D3301v1/3302v1/4302v1 - F5D8235v3 GPIO Init\n"); gpios = 1 << 10 | 1 << 11 | 1 << 13; } if (nvram_match("boot_hw_model", "E1000") && (nvram_match("boot_hw_ver", "2.0") || nvram_match("boot_hw_ver", "2.1"))) { printk(KERN_EMERG "E1000v2/v21 GPIO Init\n"); gpios = 1 << 6 | 1 << 7 | 1 << 8; } if (nvram_match("boot_hw_model", "E4200") && nvram_match("boot_hw_ver", "1.0")) { printk(KERN_EMERG "E4200 GPIO Init\n"); gpios = 1 << 3 | 1 << 5; } if (nvram_match("boardnum", "01") && nvram_match("boardtype", "0xb4cf") && nvram_match("boardrev", "0x1100")) { printk(KERN_EMERG "WNDR3400 GPIO Init\n"); gpios = 1 << 0 | 1 << 1 | 1 << 2 | 1 << 3 | 1 << 7; } if (nvram_match("boardnum", "01") && nvram_match("boardtype", "0xF52C") && nvram_match("boardrev", "0x1101")) { printk(KERN_EMERG "WNDR4000 GPIO Init\n"); gpios = 1 << 0 | 1 << 6 | 1 << 7; } /*if (iswrt300n11) { printk(KERN_EMERG "WRT300N v1.1 GPIO Init\n"); int reset = 1 << 8; sb_gpioout(gpio_sbh, reset, 0, GPIO_DRV_PRIORITY); sb_gpioouten(gpio_sbh, reset, reset, GPIO_DRV_PRIORITY); bcm_mdelay(50); sb_gpioout(gpio_sbh, reset, reset, GPIO_DRV_PRIORITY); bcm_mdelay(20); }*/ for (i = 0; i < 16; i++) { if (gpios&1) { si_gpioreserve(gpio_sih, 1 << i, GPIO_APP_PRIORITY); } gpios>>=1; } return 0; }
static int __init gpio_init(void) { int i; int gpios = 0; printk(KERN_INFO "init gpio code\n"); if (!(gpio_sih = si_kattach(SI_OSH))) return -ENODEV; si_gpiosetcore(gpio_sih); set_hc595_core(gpio_sih); if ((gpio_major = register_chrdev(127, "gpio", &gpio_fops)) < 0) { return gpio_major; } gpio_class = class_create(THIS_MODULE, "gpio"); for (i = 0; i < ARRAYSIZE(gpio_file); i++) { device_create(gpio_class, NULL, MKDEV(127, i), NULL, gpio_file[i].name); } uint boardnum = bcm_strtoul(nvram_safe_get("boardnum"), NULL, 0); if (boardnum == 00 && nvram_match("boardtype", "0xF646") && nvram_match("boardrev", "0x1100") && nvram_match("melco_id", "RD_BB12068")) { printk(KERN_EMERG "Buffalo WZR-1750DHP\n"); isbuffalo = 1; set_hc595_reset(); gpio_init_flag = 1; return 0; } if (boardnum == 00 && nvram_match("boardtype", "0x0665") && nvram_match("boardrev", "0x1103") && nvram_match("melco_id", "RD_BB13049")) { printk(KERN_EMERG "Buffalo WXR-1900DHP\n"); isbuffalowxr = 1; gpio_init_flag = 1; return 0; } if ((!strncmp(nvram_safe_get("boardnum"),"2013",4) || !strncmp(nvram_safe_get("boardnum"),"2014",4)) && nvram_match("boardtype", "0x0646") && nvram_match("boardrev", "0x1110") && nvram_match("0:rxchain", "7")) { printk(KERN_EMERG "Buffalo WZR-900DHP\n"); isbuffalo = 1; set_hc595_reset(); gpio_init_flag = 1; return 0; } if ((!strncmp(nvram_safe_get("boardnum"),"2013",4) || !strncmp(nvram_safe_get("boardnum"),"2014",4)) && nvram_match("boardtype", "0x0646") && nvram_match("boardrev", "0x1110") && nvram_match("0:rxchain", "3")) { printk(KERN_EMERG "Buffalo WZR-600DHP2\n"); isbuffalo = 1; set_hc595_reset(); gpio_init_flag = 1; return 0; } if ((boardnum == 0) && nvram_match("boardtype", "0x0646") && (nvram_match("boardrev", "0x1100"))) { printk(KERN_EMERG "Asus-RT-AC56U init\n"); isac66 = 1; } if (nvram_match("model","RT-AC68U")) { printk(KERN_EMERG "Asus-RT-AC68U init\n"); isac68 = 1; } else if ((boardnum != 24) && nvram_match("boardtype", "0x0646") && (nvram_match("boardrev", "0x1100"))) { printk(KERN_EMERG "Asus-RT-AC68U init\n"); isac68 = 1; } if ((boardnum == 24) && nvram_match("boardtype", "0x0646") && nvram_match("boardrev", "0x1110") && !nvram_match("gpio6", "wps_led")) { printk(KERN_EMERG "DLink DIR-868 init\n"); isac66 = 1; } if ((boardnum == 679) && nvram_match("boardtype", "0x0646") && (nvram_match("boardrev", "0x1110"))) { printk(KERN_EMERG "Netgear AC1450/R6250/R6300v2/EX6200 init\n"); gpios = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 | 1<<9 | 1<<10 | 1<<11 | 1<<15; } if ((boardnum == 32) && nvram_match("boardtype", "0x0665") && (nvram_match("boardrev", "0x1301"))) { printk(KERN_EMERG "Netgear R7000 init\n"); gpios = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 | 1<<9 | 1<<10 | 1<<11 | 1<<15; } if ((boardnum == 32) && nvram_match("boardtype", "0x0665") && (nvram_match("boardrev", "0x1101"))) { printk(KERN_EMERG "Netgear R8000 init\n"); gpios = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7 | 1<<8 | 1<<9 | 1<<10 | 1<<11 | 1<<15; } for (i = 0; i < 16; i++) { if (gpios&1) { si_gpioreserve(gpio_sih, 1 << i, GPIO_APP_PRIORITY); } } gpio_init_flag = 1; return 0; }