Esempio n. 1
0
void ag7100_reset(ag7100_mac_t *mac) 
{
    uint32_t mask;

    //ag7100_reg_rmw_set(mac, AG7100_MAC_CFG1, AG7100_MAC_CFG1_SOFT_RST);
    mask = ag7100_reset_mask(mac->mac_unit);
        
    /*
     * put into reset, hold, pull out.
     */

    ar7100_reg_rmw_clear(AR7100_GPIO_INT_MASK,          /* set gpio to intr disable mode */
                      (1 << (GPIO_MDC - AR7100_GPIO_IRQ_BASE)));
    ar7100_reg_rmw_clear(AR7100_GPIO_OE, (1 << GPIO_MDC));  /* set gpio to out val mode */
    ar7100_reg_rmw_set(AR7100_GPIO_OUT, (1 << GPIO_MDC));    /* out val */
    
    ar7100_reg_rmw_clear(AR7100_GPIO_INT_MASK,          /* set gpio to intr disable mode */
                      (1 << (GPIO_MDIO - AR7100_GPIO_IRQ_BASE)));
    ar7100_reg_rmw_clear(AR7100_GPIO_OE, (1 << GPIO_MDIO));  /* set gpio to out val mode */
    ar7100_reg_rmw_set(AR7100_GPIO_OUT, (1 << GPIO_MDIO));    /* out val */
         
    ar7100_reg_rmw_set(AR7100_RESET, mask);  /* reset switch */
    A_MDELAY(200);
    ar7100_reg_rmw_clear(AR7100_RESET, mask);
    A_MDELAY(200);
}
Esempio n. 2
0
void ar7100_gpio_config_int(int gpio, 
                       ar7100_gpio_int_type_t type,
                       ar7100_gpio_int_pol_t polarity)
{
    u32 val;

    /*
     * allow edge sensitive/rising edge too
     */
    if (type == INT_TYPE_LEVEL) {
        /* level sensitive */
        ar7100_reg_rmw_set(AR7100_GPIO_INT_TYPE, (1 << gpio));
    }
    else {
       /* edge triggered */
       val = ar7100_reg_rd(AR7100_GPIO_INT_TYPE);
       val &= ~(1 << gpio);
       ar7100_reg_wr(AR7100_GPIO_INT_TYPE, val);
    }

    if (polarity == INT_POL_ACTIVE_HIGH) {
        ar7100_reg_rmw_set (AR7100_GPIO_INT_POLARITY, (1 << gpio));
    }
    else {
       val = ar7100_reg_rd(AR7100_GPIO_INT_POLARITY);
       val &= ~(1 << gpio);
       ar7100_reg_wr(AR7100_GPIO_INT_POLARITY, val);
    }

    ar7100_reg_rmw_set(AR7100_GPIO_INT_ENABLE, (1 << gpio));
}
Esempio n. 3
0
File: smi.c Progetto: janfj/dd-wrt
void ar9100_configGpioPin(int gpio, int dir, int intr)
{
	if (dir == GPIO_DIR_OUT)
		ar7100_reg_rmw_set(AR7100_GPIO_OE, (1 << gpio))
	else
		ar7100_reg_rmw_clear(AR7100_GPIO_OE, (1 << gpio));

	if (intr == GPIO_INT_ENABLE)
		ar7100_reg_rmw_set(AR7100_GPIO_INT_MASK, (1 << gpio))
	else
		ar7100_reg_rmw_clear(AR7100_GPIO_INT_MASK, (1 << gpio));
}
Esempio n. 4
0
File: gpio.c Progetto: janfj/dd-wrt
void ar7100_gpio_out_val(int gpio, int val)
{
	if (val & 0x1) {
		ar7100_reg_rmw_set(AR7100_GPIO_OUT, (1 << gpio));
	} else {
		ar7100_reg_rmw_clear(AR7100_GPIO_OUT, (1 << gpio));
	}
}
Esempio n. 5
0
void ar7100_gpio_out_val(int gpio, int val)
{
	if (val & 0x1) {
		ar7100_reg_rmw_set(AR7100_GPIO_OUT, (1 << gpio));
	} else {
		ar7100_reg_rmw_clear(AR7100_GPIO_OUT, (1 << gpio));
	}
	(void)ar7100_reg_rd(AR7100_GPIO_OUT);	/* flush write to hardware */
}
Esempio n. 6
0
void ap_usb_led_off(void)
{
#ifdef CONFIG_WZRAG300NH
	set_wl0_gpio(3, 1);
#elif CONFIG_WNDR3700
	ar7100_reg_rmw_set(AR7100_RESET, AR7100_RESET_GE1_PHY);
#elif AP_USB_LED_GPIO
	ar7100_set_gpio(AP_USB_LED_GPIO, USB_LED_OFF);
#endif
}
Esempio n. 7
0
static void enable_ethernet(void)
{
	unsigned int mask = ag7100_reset_mask(0);
	/*
	 * put into reset, hold, pull out.
	 */
	ar7100_reg_rmw_set(AR7100_RESET, mask);
	udelay(1000 * 1000);
	ar7100_reg_rmw_clear(AR7100_RESET, mask);
	udelay(1000 * 1000);
	udelay(20);
}
Esempio n. 8
0
static void
ar7100_gpio_intr_enable(unsigned int irq)
{
    ar7100_reg_rmw_set(AR7100_GPIO_INT_MASK, 
                      (1 << (irq - AR7100_GPIO_IRQ_BASE)));
}
Esempio n. 9
0
void
ar7100_gpio_config_output(int gpio)
{
    ar7100_reg_rmw_set(AR7100_GPIO_OE, (1 << gpio));
}
Esempio n. 10
0
/*
 * We use 0xa0003000, because the first way is locked into cache to give
 * us a rudimentary stack
 */
void ar7100_ddr_tap_config(void)
{
    uint8_t set, prev, dummy;
    int i, j, k, floor, ceiling;
    uint16_t *p = 0xa0003000, *p_ca = 0x80003000;

    ar7100_reg_rmw_set(AR7100_DDR_CONFIG, AR7100_DDR_CONFIG_16BIT);

    for(i = 0; i < sizeof(tap_settings); i++) {
        set = tap_settings[i];
        ar7100_ddr_tap_set(set);

        printf("trying %#x...", set);
        for(j = 0; j < 4; j++)
            *(p + j) = tap_pattern[j];

        /*
         * get the cacheline
         */
        dummy = *p_ca;

        if ((*(p_ca + 2)) == tap_pattern[2]) {
            floor = i;
            printf("worked; floor %d\n", i);
            break;
        }
        printf("didnt work written %#x read %#x\n", tap_pattern[2], 
                *(p_ca + 2));
        flush_cache(p_ca, 8);
    }

    for(k = sizeof(tap_settings) - 1; k > i; k--) {
        set = tap_settings[k];
        ar7100_ddr_tap_set(set);

        printf("trying %#x...", set);
        for(j = 0; j < 4; j++)
            *(p + j) = tap_pattern[j];

        dummy = *p_ca;

        if ((*(p_ca + 2)) == tap_pattern[2]) {
            ceiling = k;
            printf("worked; ceiling %d\n", k);
            break;
        }
        printf("didnt work written %#x read %#x\n", tap_pattern[2], 
                *(p_ca + 2));
        flush_cache(p_ca, 8);
    }
    /*
     * If the min and max delay both worked, lets pick a default
     */
    printf("floor %d ceil %d size-1 %d\n",
            floor, ceiling, (sizeof(tap_settings) - 1));

    if ((floor == 0) && (ceiling == (sizeof(tap_settings) - 1))) 
        set = AR7100_DDR_TAP_DEFAULT;
    else {
        i = ((ceiling - floor)/2) + floor;
        set = tap_settings[i];
        printf("i %d\n", i);
    }

    printf("Setting Tap to %#x\n", set);
    ar7100_ddr_tap_set(set);
    udelay(1);
}
Esempio n. 11
0
void ar7100_gpio_config_output(int gpio)
{
	ar7100_reg_rmw_set(AR7100_GPIO_OE, (1 << gpio));
	(void)ar7100_reg_rd(AR7100_GPIO_OE);	/* flush write to hardware */
}