int wldev_set_country(
	struct net_device *dev, char *country_code, bool notify, bool user_enforced)
{
	int error = -1;
	wl_country_t cspec = {{0}, 0, {0}};
	scb_val_t scbval;
	char smbuf[WLC_IOCTL_SMLEN];
#ifdef CUSTOMER_HW_ONE
	uint32 chan_buf[WL_NUMCHANNELS];
	wl_uint32_list_t *list;
	channel_info_t ci;
	int retry = 0;
	int chan = 1;
#endif
	if (!country_code)
		return error;

	bzero(&scbval, sizeof(scb_val_t));
	error = wldev_iovar_getbuf(dev, "country", NULL, 0, &cspec, sizeof(cspec), NULL);
	if (error < 0) {
		WLDEV_ERROR(("%s: get country failed = %d\n", __FUNCTION__, error));
		return error;
	}

	if ((error < 0) ||
	    (strncmp(country_code, cspec.country_abbrev, WLC_CNTRY_BUF_SZ) != 0)) {

		if (user_enforced) {
			bzero(&scbval, sizeof(scb_val_t));
			error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), true);
			if (error < 0) {
				WLDEV_ERROR(("%s: set country failed due to Disassoc error %d\n",
					__FUNCTION__, error));
				return error;
			}
		}

#ifdef CUSTOMER_HW_ONE
		error = wldev_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan), 1);
		if (error < 0) {
			WLDEV_ERROR(("%s: set country failed due to channel 1 error %d\n",
				__FUNCTION__, error));
			return error;
		}
	}

get_channel_retry:
	if ((error = wldev_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci), 0))) {
		WLDEV_ERROR(("%s: get channel fail!\n", __FUNCTION__));
		return error;
	}
	ci.scan_channel = dtoh32(ci.scan_channel);
	if (ci.scan_channel) {
		retry++;
		printf("%s: scan in progress, retry %d!\n", __FUNCTION__, retry);
		if (retry > 3)
			return -EBUSY;
		bcm_mdelay(1000);
		goto get_channel_retry;
	}
#endif
		cspec.rev = -1;
		memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ);
		memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ);
		get_customized_country_code((char *)&cspec.country_abbrev, &cspec);
		error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec),
			smbuf, sizeof(smbuf), NULL);
		if (error < 0) {
#ifdef CUSTOMER_HW_ONE
			if (strcmp(cspec.country_abbrev, DEF_COUNTRY_CODE) != 0) {
				strcpy(country_code, DEF_COUNTRY_CODE);
				retry = 0;
				goto get_channel_retry;
			}
			else {
#endif
				WLDEV_ERROR(("%s: set country for %s as %s rev %d failed\n",
					__FUNCTION__, country_code, cspec.ccode, cspec.rev));
				return error;
			}
#ifdef CUSTOMER_HW_ONE
		}
		/* check if there are available channels */
		else {
			if (strcmp(country_code, DEF_COUNTRY_CODE) != 0) {
				list = (wl_uint32_list_t *)(void *)chan_buf;
				list->count = htod32(WL_NUMCHANNELS);
				if ((error = wldev_ioctl_no_memset(dev, WLC_GET_VALID_CHANNELS, &chan_buf, sizeof(chan_buf), 0))) {
					WLDEV_ERROR(("%s: get channel list fail! %d\n", __FUNCTION__, error));
					return error;
				}
				/* if NULL, set default country code instead and set country code again */
				printf("%s: channel_count = %d\n", __FUNCTION__, list->count);
				if (list->count == 0) {
					strcpy(country_code, DEF_COUNTRY_CODE);
					retry = 0;
					goto get_channel_retry;
				}
		}	
#endif
		dhd_bus_country_set(dev, &cspec, notify);
		WLDEV_ERROR(("%s: set country for %s as %s rev %d\n",
			__FUNCTION__, country_code, cspec.ccode, cspec.rev));
	}
#ifdef CUSTOMER_HW_ONE
	wl_cfg80211_abort_connecting();
#endif
	return 0;
}
int
wldev_set_apsta(struct net_device *dev, bool enable)
{
   	int res = 0;
   	int mpc = 0;
   	int concr_mode = 0;
	int roam_off;
   	char smbuf[WLC_IOCTL_SMLEN];
	bss_setbuf_t bss_setbuf;
	int frameburst;

        memset(smbuf, 0, sizeof(smbuf));

	printf("%s: enter\n", __FUNCTION__);

   	if (!dev) {
                  WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__));
                  return -1;
   	}

	if (enable){
		/* wait for interface ready */
		wait_for_ap_ready(1);

		if ( ap_net_dev == NULL ) {
                        WLDEV_ERROR(("%s ap_net_dev == NULL\n", __FUNCTION__));
                        goto fail;
		}

		concr_mode = 1;
		if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) {
			printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res);
		}


        rxglom_fail_count = RXGLOM_CONCUR_MODE_FAIL_COUNT;
        max_cntl_timeout =  MAX_CONCUR_MODE_CNTL_TIMEOUT;


		roam_off = 1;
		if((res = wldev_iovar_setint(dev, "roam_off", roam_off)))
			printf("%s fail to set roam_off res[%d]\n", __FUNCTION__,res);
		
   		mpc = 0;
		if ((res = wldev_iovar_setint(dev, "mpc", mpc))) {
			WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__));
			goto fail;
		}	

		if ((res = wl_iw_set_ap_security(ap_net_dev, &ap_cfg)) != 0) {
			WLDEV_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res));
			goto fail;
		} 

		if(wl_get_drv_status(wlcfg_drv_priv,CONNECTED,dev))
		{
			u32 chanspec = 0;
			int err;
			if(wldev_iovar_getint(dev, "chanspec", (s32 *)&chanspec) == BCME_OK)
			{
				printf("%s get Chanspec [%0x]\n",__func__ ,chanspec);
				if((err = wldev_iovar_setint(ap_net_dev, "chanspec", chanspec)) == BCME_BADCHAN) {
					printf("%s set Chanspec failed\n",__func__);
				} else
					printf("%s set Chanspec OK\n",__func__);
			}
			else
				printf("%s get Chanspec failed\n",__func__);

		}
		else
			printf("%s Sta is not connected with any AP\n",__func__);

			bss_setbuf.cfg = 1;
			bss_setbuf.val = 1;  /* up the interface */

			if ((res = wldev_iovar_setbuf_bsscfg(dev, "bss", &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf), 1, NULL)) < 0){
				WLDEV_ERROR(("%s: ERROR:%d, set bss up failed\n", __FUNCTION__, res));
				goto fail;
        	}

	        bcm_mdelay(500);

            printf("prepare set frameburst \n");
            frameburst = 1;
            if ((res = wldev_ioctl(dev, WLC_SET_FAKEFRAG, &frameburst, sizeof(frameburst), 0))) {
                printf("%s fail to set frameburst !!\n", __FUNCTION__);
            }

		if ((res = wldev_iovar_setint(dev, "allmulti", 1))) {
            		WLDEV_ERROR(("%s: ERROR:%d, set allmulti failed\n", __FUNCTION__, res));
            		goto fail;
		}

#if !defined(WLCREDALL)
		if ((res = wldev_iovar_setint(dev, "bus:credall", 1))) {
			WLDEV_ERROR(("%s: ERROR:%d, set credall failed\n", __FUNCTION__, res));
			goto fail;
		}
#endif


		set_ap_channel(dev,&ap_cfg);
		ap_net_dev->operstate = IF_OPER_UP;
	} else {
		if ((res = wl_softap_stop(ap_net_dev))){
           		WLDEV_ERROR(("%s: ERROR:%d, call wl_softap_stop failed\n", __FUNCTION__, res));
           		goto fail;
		}

		concr_mode = 0;
		if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) {
				printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res);
			}


        rxglom_fail_count = RXGLOM_FAIL_COUNT;
        max_cntl_timeout =  MAX_CNTL_TIMEOUT;
        scan_suppress_flag = 0;


	/* 2012-09-21 Stop roam when start Concurrent ++++ */
	roam_off = 0;
	if((res = wldev_iovar_setint(dev, "roam_off", roam_off)))
			printf("%s fail to set roam_off res[%d]\n", __FUNCTION__,res);

	mpc = 1;
	     	if ((res = wldev_iovar_setint(dev, "mpc", mpc))) {
        	   	WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__));
           		goto fail;
	      	}

#if !defined(WLCREDALL)
		if ((res = wldev_iovar_setint(dev, "bus:credall", 0))) {
			WLDEV_ERROR(("%s fail to set credall\n", __FUNCTION__));
			goto fail;
		}
#endif

        printf("prepare set frameburst \n");
        frameburst = 0;
        if ((res = wldev_ioctl(dev, WLC_SET_FAKEFRAG, &frameburst, sizeof(frameburst), 0))) {
            printf("%s fail to set frameburst !!\n", __FUNCTION__);
        }


        wlcfg_drv_priv->dongle_connected = 0;
        wldev_adj_apsta_scan_param(dev,wlcfg_drv_priv->dongle_connected);
	}

fail:
    return res;
}
Example #3
0
int wldev_set_country(
	struct net_device *dev, char *country_code)
{
	int error = -1;
	wl_country_t cspec = {{0}, 0, {0}};
	scb_val_t scbval;
	char smbuf[WLC_IOCTL_SMLEN];
	
	uint32 chan_buf[WL_NUMCHANNELS];
	wl_uint32_list_t *list;
	channel_info_t ci;
	int retry = 0;
	int chan = 1;
	

	if (!country_code)
		return error;

	error = wldev_iovar_getbuf(dev, "country", &cspec, sizeof(cspec),
		smbuf, sizeof(smbuf), NULL);
	if (error < 0)
		WLDEV_ERROR(("%s: get country failed = %d\n", __FUNCTION__, error));

	if ((error < 0) ||
	    (strncmp(country_code, smbuf, WLC_CNTRY_BUF_SZ) != 0)) {
		bzero(&scbval, sizeof(scb_val_t));
		error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), 1);
		if (error < 0) {
			WLDEV_ERROR(("%s: set country failed due to Disassoc error %d\n",
				__FUNCTION__, error));
			return error;
		}
		error = wldev_ioctl(dev, WLC_SET_CHANNEL, &chan, sizeof(chan), 1);
		if (error < 0) {
			WLDEV_ERROR(("%s: set country failed due to channel 1 error %d\n",
				__FUNCTION__, error));
			return error;
		}
	}

get_channel_retry:
	if ((error = wldev_ioctl(dev, WLC_GET_CHANNEL, &ci, sizeof(ci), 0))) {
		WLDEV_ERROR(("%s: get channel fail!\n", __FUNCTION__));
		return error;
	}
	ci.scan_channel = dtoh32(ci.scan_channel);
	if (ci.scan_channel) {
		retry++;
		printf("%s: scan in progress, retry %d!\n", __FUNCTION__, retry);
		if (retry > 3)
			return -EBUSY;
		bcm_mdelay(1000);
		goto get_channel_retry;
	}

	cspec.rev = -1;
	memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ);
	memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ);
	get_customized_country_code((char *)&cspec.country_abbrev, &cspec);
	error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec),
		smbuf, sizeof(smbuf), NULL);
	if (error < 0) {
	
		if (strcmp(cspec.country_abbrev, DEF_COUNTRY_CODE) != 0) {
			strcpy(country_code, DEF_COUNTRY_CODE);
			retry = 0;
			goto get_channel_retry;
		}
		else {
			WLDEV_ERROR(("%s: set country for %s as %s rev %d failed\n",
				__FUNCTION__, country_code, cspec.ccode, cspec.rev));
			return error;
		}
	}
	
	else {
		if (strcmp(country_code, DEF_COUNTRY_CODE) != 0) {
			list = (wl_uint32_list_t *)(void *)chan_buf;
			list->count = htod32(WL_NUMCHANNELS);
			if ((error = wldev_ioctl_no_memset(dev, WLC_GET_VALID_CHANNELS, &chan_buf, sizeof(chan_buf), 0))) {
				WLDEV_ERROR(("%s: get channel list fail! %d\n", __FUNCTION__, error));
				return error;
			}
			
			printf("%s: channel_count = %d\n", __FUNCTION__, list->count);
			if (list->count == 0) {
				strcpy(country_code, DEF_COUNTRY_CODE);
				retry = 0;
				goto get_channel_retry;
			}
		}	
	}
	
	dhd_bus_country_set(dev, &cspec);
	printk(KERN_INFO "[WLAN] %s: set country for %s as %s rev %d\n",
		__func__, country_code, cspec.ccode, cspec.rev);
	
	wl_cfg80211_abort_connecting();
	
	return 0;
}
Example #4
0
/* support only 16-bit word write into srom */
int
srom_write(uint bus, void *curmap, void *osh, uint byteoff, uint nbytes, uint16 *buf)
{
	uint16 *srom;
	uint i, off, nw, crc_range;
	uint16 image[SPROM_SIZE], *p;
	uint8 crc;
	volatile uint32 val32;

	/* check input - 16-bit access only */
	if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
		return 1;

	crc_range = ((bus == PCMCIA_BUS) ? SPROM_SIZE : SPROM_CRC_RANGE) * 2;

	/* if changes made inside crc cover range */
	if (byteoff < crc_range) {
		nw = (((byteoff + nbytes) > crc_range) ? byteoff + nbytes : crc_range) / 2;
		/* read data including entire first 64 words from srom */
		if (srom_read(bus, curmap, osh, 0, nw * 2, image))
			return 1;
		/* make changes */
		bcopy((void*)buf, (void*)&image[byteoff / 2], nbytes);
		/* calculate crc */
		htol16_buf(image, crc_range);
		crc = ~crc8((uint8 *)image, crc_range - 1, CRC8_INIT_VALUE);
		ltoh16_buf(image, crc_range);
		image[(crc_range / 2) - 1] = (crc << 8) | (image[(crc_range / 2) - 1] & 0xff);
		p = image;
		off = 0;
	} else {
		p = buf;
		off = byteoff / 2;
		nw = nbytes / 2;
	}

	if (bus == PCI_BUS) {
		srom = (uint16*)((uint)curmap + PCI_BAR0_SPROM_OFFSET);
		/* enable writes to the SPROM */
		val32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32));
		val32 |= SPROM_WRITEEN;
		OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32);
		bcm_mdelay(500);
		/* write srom */
		for (i = 0; i < nw; i++) {
			W_REG(&srom[off + i], p[i]);
			bcm_mdelay(20);
		}
		/* disable writes to the SPROM */
		OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32 & ~SPROM_WRITEEN);
	} else if (bus == PCMCIA_BUS) {
		/* enable writes to the SPROM */
		if (sprom_cmd_pcmcia(osh, SROM_WEN))
			return 1;
		bcm_mdelay(500);
		/* write srom */
		for (i = 0; i < nw; i++) {
			sprom_write_pcmcia(osh, (uint16)(off + i), p[i]);
			bcm_mdelay(20);
		}
		/* disable writes to the SPROM */
		if (sprom_cmd_pcmcia(osh, SROM_WDS))
			return 1;
	} else {
		return 1;
	}

	bcm_mdelay(500);
	return 0;
}
Example #5
0
static int
wl_android_set_auto_channel(struct net_device *dev, const char* string_num,
	char* command, int total_len)
{
	int channel;
	int chosen = 0;
	int retry = 0;
	int ret = 0;

	/* Restrict channel to 1 - 7: 2GHz, 20MHz BW, No SB */
	u32 req_buf[8] = {7, 0x2B01, 0x2B02, 0x2B03, 0x2B04, 0x2B05, 0x2B06,
		0x2B07};

	/* Auto channel select */
	wl_uint32_list_t request;

	channel = bcm_atoi(string_num);
	DHD_INFO(("%s : HAPD_AUTO_CHANNEL = %d\n", __FUNCTION__, channel));

	if (channel == 20)
		ret = wldev_ioctl(dev, WLC_START_CHANNEL_SEL, (void *)&req_buf,
			sizeof(req_buf), true);
	else { /* channel == 0 */
		request.count = htod32(0);
		ret = wldev_ioctl(dev, WLC_START_CHANNEL_SEL, (void *)&request,
			sizeof(request), true);
	}

	if (ret < 0) {
		DHD_ERROR(("%s: can't start auto channel scan, err = %d\n",
			__FUNCTION__, ret));
		channel = 0;
		goto done;
	}

	/* Wait for auto channel selection, max 2500 ms */
	bcm_mdelay(500);

	retry = 10;
	while (retry--) {
		ret = wldev_ioctl(dev, WLC_GET_CHANNEL_SEL, &chosen, sizeof(chosen),
			false);
		if (ret < 0 || dtoh32(chosen) == 0) {
			DHD_INFO(("%s: %d tried, ret = %d, chosen = %d\n",
				__FUNCTION__, (10 - retry), ret, chosen));
			bcm_mdelay(200);
		}
		else {
			channel = (u16)chosen & 0x00FF;
			DHD_ERROR(("%s: selected channel = %d\n", __FUNCTION__, channel));
			break;
		}
	}

	if (retry == 0) {
		DHD_ERROR(("%s: auto channel timed out, failed\n", __FUNCTION__));
		channel = 0;
	}

done:
	snprintf(command, 4, "%d", channel);
	DHD_INFO(("%s: command result is %s\n", __FUNCTION__, command));

	return 4;
}
int
wldev_set_apsta(struct net_device *dev, bool enable)
{
   	int res = 0;
   	int mpc = 0;
	int concr_mode = 0;
   	char smbuf[WLC_IOCTL_SMLEN];
	bss_setbuf_t bss_setbuf;

        memset(smbuf, 0, sizeof(smbuf));

	printf("%s: enter\n", __FUNCTION__);

   	if (!dev) {
                  WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__));
                  return -1;
   	}

	if (enable){
		/* wait for interface ready */
		wait_for_ap_ready(1); //broacom 0405

		if ( ap_net_dev == NULL ) {
                        WLDEV_ERROR(("%s ap_net_dev == NULL\n", __FUNCTION__));
                        goto fail;
		}

		//2012-09-10 CT2 set Concr_mode ++++
		concr_mode = 1;
		if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) {
					printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res);
		}
		//2012-09-10 CT2 set Concr_mode ++++

   		mpc = 0;
      	        if ((res = wldev_iovar_setint(dev, "mpc", mpc))) {
           	        WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__));
           	        goto fail;
      	        }	

         	if ((res = wl_iw_set_ap_security(ap_net_dev, &ap_cfg)) != 0) {
           	        WLDEV_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res));
         	        goto fail;
                } 
                
                bss_setbuf.cfg = 1;
                bss_setbuf.val = 1;  /* up the interface */

                if ((res = wldev_iovar_setbuf_bsscfg(dev, "bss", &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf), 1, NULL)) < 0){
           	         WLDEV_ERROR(("%s: ERROR:%d, set bss up failed\n", __FUNCTION__, res));
           	         goto fail;
        	}

	        bcm_mdelay(500);

		if ((res = wldev_iovar_setint(dev, "allmulti", 1))) {
            		WLDEV_ERROR(("%s: ERROR:%d, set allmulti failed\n", __FUNCTION__, res));
            		goto fail;
		}
//BRCM_APSTA_START
		set_ap_channel(dev,&ap_cfg);
		ap_net_dev->operstate = IF_OPER_UP;
//BRCM_APSTA_END
	} else {
		if ((res = wl_softap_stop(ap_net_dev))){
           		WLDEV_ERROR(("%s: ERROR:%d, call wl_softap_stop failed\n", __FUNCTION__, res));
           		goto fail;
		}

		//2012-09-10 CT2 set Concr_mode ++++
		concr_mode = 0;
		if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) {
				printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res);
		}
		//2012-09-10 CT2 set Concr_mode ++++

    		mpc = 1;
	     	if ((res = wldev_iovar_setint(dev, "mpc", mpc))) {
        	   	WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__));
           		goto fail;
	      	}	
	}

fail:
    return res;
}
int
wldev_set_apsta(struct net_device *dev, bool enable)
{
   	int res = 0;
   	int mpc = 0;
   	int concr_mode = 0;
	int roam_off;
   	char smbuf[WLC_IOCTL_SMLEN];
	bss_setbuf_t bss_setbuf;
	int frameburst;

        memset(smbuf, 0, sizeof(smbuf));

	printf("%s: enter\n", __FUNCTION__);

   	if (!dev) {
                  WLDEV_ERROR(("%s: dev is null\n", __FUNCTION__));
                  return -1;
   	}

	if (enable){
		
		wait_for_ap_ready(1); 

		if ( ap_net_dev == NULL ) {
                        WLDEV_ERROR(("%s ap_net_dev == NULL\n", __FUNCTION__));
                        goto fail;
		}

		
				concr_mode = 1;
				if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) {
						printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res);
				}
		

		
		roam_off = 1;
		if((res = wldev_iovar_setint(dev, "roam_off", roam_off)))
				printf("%s fail to set roam_off res[%d]\n", __FUNCTION__,res);
		
		
   		mpc = 0;
      	        if ((res = wldev_iovar_setint(dev, "mpc", mpc))) {
           	        WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__));
           	        goto fail;
      	        }	

         	if ((res = wl_iw_set_ap_security(ap_net_dev, &ap_cfg)) != 0) {
           	        WLDEV_ERROR((" %s ERROR setting SOFTAP security in :%d\n", __FUNCTION__, res));
         	        goto fail;
                } 
                
                bss_setbuf.cfg = 1;
                bss_setbuf.val = 1;  

                if ((res = wldev_iovar_setbuf_bsscfg(dev, "bss", &bss_setbuf, sizeof(bss_setbuf), smbuf, sizeof(smbuf), 1, NULL)) < 0){
           	         WLDEV_ERROR(("%s: ERROR:%d, set bss up failed\n", __FUNCTION__, res));
           	         goto fail;
        	}

	        bcm_mdelay(500);

            printf("prepare set frameburst \n");
            frameburst = 1;
            if ((res = wldev_ioctl(dev, WLC_SET_FAKEFRAG, &frameburst, sizeof(frameburst), 0))) {
                printf("%s fail to set frameburst !!\n", __FUNCTION__);
            }

		if ((res = wldev_iovar_setint(dev, "allmulti", 1))) {
            		WLDEV_ERROR(("%s: ERROR:%d, set allmulti failed\n", __FUNCTION__, res));
            		goto fail;
		}
		set_ap_channel(dev,&ap_cfg);
		ap_net_dev->operstate = IF_OPER_UP;
	} else {
		if ((res = wl_softap_stop(ap_net_dev))){
           		WLDEV_ERROR(("%s: ERROR:%d, call wl_softap_stop failed\n", __FUNCTION__, res));
           		goto fail;
		}

	
		concr_mode = 0;
		if ((res = wldev_iovar_setint(dev, "concr_mode_set", concr_mode))) {
				printf("%s fail to set concr_mode res[%d]\n", __FUNCTION__,res);
			}
	

	
	roam_off = 0;
	if((res = wldev_iovar_setint(dev, "roam_off", roam_off)))
			printf("%s fail to set roam_off res[%d]\n", __FUNCTION__,res);
	

	mpc = 1;
	     	if ((res = wldev_iovar_setint(dev, "mpc", mpc))) {
        	   	WLDEV_ERROR(("%s fail to set mpc\n", __FUNCTION__));
           		goto fail;
	      	}

        printf("prepare set frameburst \n");
        frameburst = 0;
        if ((res = wldev_ioctl(dev, WLC_SET_FAKEFRAG, &frameburst, sizeof(frameburst), 0))) {
            printf("%s fail to set frameburst !!\n", __FUNCTION__);
        }
	}

fail:
    return res;
}
Example #8
0
/* support only 16-bit word write into srom */
int
srom_write(uint bustype, void *curmap, osl_t *osh, uint byteoff, uint nbytes, uint16 *buf)
{
	uint16 *srom;
	uint i, nw, crc_range;
	uint16 image[SPROM_SIZE];
	uint8 crc;
	volatile uint32 val32;

	ASSERT(bustype == BUSTYPE(bustype));

	/* check input - 16-bit access only */
	if (byteoff & 1 || nbytes & 1 || (byteoff + nbytes) > (SPROM_SIZE * 2))
		return 1;

	/* Are we writing the whole thing at once? */
	if ((byteoff == 0) &&
	    ((nbytes == SPROM_SIZE) ||
	     (nbytes == (SPROM_CRC_RANGE * 2)) ||
	     (nbytes == (SROM4_WORDS * 2)))) {
		crc_range = nbytes;
		bcopy((void*)buf, (void*)image, nbytes);
		nw = nbytes / 2;
	} else {
		if ((BUSTYPE(bustype) == PCMCIA_BUS) || (BUSTYPE(bustype) == SDIO_BUS))
			crc_range = SPROM_SIZE;
		else
			crc_range = SPROM_CRC_RANGE * 2;	/* Tentative */

		nw = crc_range / 2;
		/* read first 64 words from srom */
		if (srom_read(bustype, curmap, osh, 0, crc_range, image))
			return 1;
		if (image[SROM4_SIGN] == SROM4_SIGNATURE) {
			crc_range = SROM4_WORDS;
			nw = crc_range / 2;
			if (srom_read(bustype, curmap, osh, 0, crc_range, image))
				return 1;
		}
		/* make changes */
		bcopy((void*)buf, (void*)&image[byteoff / 2], nbytes);
	}

	/* calculate crc */
	htol16_buf(image, crc_range);
	crc = ~hndcrc8((uint8 *)image, crc_range - 1, CRC8_INIT_VALUE);
	ltoh16_buf(image, crc_range);
	image[(crc_range / 2) - 1] = (crc << 8) | (image[(crc_range / 2) - 1] & 0xff);

	if (BUSTYPE(bustype) == PCI_BUS) {
		srom = (uint16*)((uchar*)curmap + PCI_BAR0_SPROM_OFFSET);
		/* enable writes to the SPROM */
		val32 = OSL_PCI_READ_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32));
		val32 |= SPROM_WRITEEN;
		OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32);
		bcm_mdelay(WRITE_ENABLE_DELAY);
		/* write srom */
		for (i = 0; i < nw; i++) {
			W_REG(osh, &srom[i], image[i]);
			bcm_mdelay(WRITE_WORD_DELAY);
		}
		/* disable writes to the SPROM */
		OSL_PCI_WRITE_CONFIG(osh, PCI_SPROM_CONTROL, sizeof(uint32), val32 &
		                     ~SPROM_WRITEEN);
	} else if (BUSTYPE(bustype) == PCMCIA_BUS) {
		/* enable writes to the SPROM */
		if (sprom_cmd_pcmcia(osh, SROM_WEN))
			return 1;
		bcm_mdelay(WRITE_ENABLE_DELAY);
		/* write srom */
		for (i = 0; i < nw; i++) {
			sprom_write_pcmcia(osh, (uint16)(i), image[i]);
			bcm_mdelay(WRITE_WORD_DELAY);
		}
		/* disable writes to the SPROM */
		if (sprom_cmd_pcmcia(osh, SROM_WDS))
			return 1;
	} else {
		return 1;
	}

	bcm_mdelay(WRITE_ENABLE_DELAY);
	return 0;
}
Example #9
0
void __init
brcm_setup(void)
{
	char *value;

	/* Get global SB handle */
	sih = si_kattach(SI_OSH);

	/* Initialize clocks and interrupts */
	si_mips_init(sih, SBMIPS_VIRTIRQ_BASE);

	if (BCM330X(current_cpu_data.processor_id) &&
		(read_c0_diag() & BRCM_PFC_AVAIL)) {
		/* 
		 * Now that the sih is inited set the  proper PFC value 
		 */	
		printk("Setting the PFC to its default value\n");
		enable_pfc(PFC_AUTO);
	}


#ifdef CONFIG_SERIAL_CORE
	/* Initialize UARTs */
	serial_setup(sih);
#endif /* CONFIG_SERIAL_CORE */

#if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)
	ide_ops = &std_ide_ops;
#endif

	/* Override default command line arguments */
	value = nvram_get("kernel_args");
	if (value && strlen(value) && strncmp(value, "empty", 5))
		strncpy(arcs_cmdline, value, sizeof(arcs_cmdline));

	if ((lanports_enable = getgpiopin(NULL, "lanports_enable", GPIO_PIN_NOTDEFINED)) ==
		GPIO_PIN_NOTDEFINED)
		lanports_enable = 0;

	/* Check if we want to enable cpu wait */
	if (nvram_match("wait", "1"))
		cpu_wait_enable = 1;

	/* wombo reset */
	if ((wombo_reset = getgpiopin(NULL, "wombo_reset", GPIO_PIN_NOTDEFINED)) !=
	    GPIO_PIN_NOTDEFINED) {
		int reset = 1 << wombo_reset;

		printk("wombo_reset set to gpio %d\n", wombo_reset);

		si_gpioout(sih, reset, 0, GPIO_DRV_PRIORITY);
		si_gpioouten(sih, reset, reset, GPIO_DRV_PRIORITY);
		bcm_mdelay(10);

		si_gpioout(sih, reset, reset, GPIO_DRV_PRIORITY);
		bcm_mdelay(20);
	}

	/* Generic setup */
	_machine_restart = bcm947xx_machine_restart;
	_machine_halt = bcm947xx_machine_halt;
	pm_power_off = bcm947xx_machine_halt;

	board_time_init = bcm947xx_time_init;
}