Ejemplo n.º 1
0
int
main(int argc, char **argv)
{
	char *kernel = NULL;
	char *ptr, *mem, *rdptr;
	void (*func)();
	int fd, size, c;
	int i;

	progname = argv[0];

	/* getopt... */
	for (i = 1; i < argc; i++) {
		if (argv[i][0] != '-') {
			if (kernel == NULL) {
				kernel = argv[i];
			}
		} else if (argv[i][0] == '-') {
			if (argv[i][1] == '0') {
				turbo_mode = !turbo_mode;
			} else {
				usage();
			}
		}
	}
	if (kernel == NULL)
		kernel = "/mmc0/netbsd.bin";

	printf("\r\nNetBSD boot loader ver." NBBOOT_VERSION "\r\n");
	rdptr = 0;

	ptr = malloc(0x2000);
	if (ptr == 0) {
		printf("No memory\r\n");
		return -1;
	}
	memset(ptr, 0, 0x2000);

	fd = open(kernel, OptRead);
	if (fd == -1) {
		free(ptr);
		printf("can't open %s\r\n", kernel);
		return -1;
	}
	switch(MCR) {
	case 0x5224:
		strcpy(ptr + 0x1100, "mem=8M console=ttySC1,115200 root=/dev/shmmc2");
		break;
	case 0x522c:
		strcpy(ptr + 0x1100, "mem=16M console=ttySC1,115200 root=/dev/shmmc2");
		break;
	case 0x526c:
		strcpy(ptr + 0x1100, "mem=32M console=ttySC1,115200 root=/dev/shmmc2");
		break;
	case 0x5274:
		strcpy(ptr + 0x1100, "mem=64M console=ttySC1,115200 root=/dev/shmmc2");
		break;
	default:
		printf("SDRAM not found!!\r\n");
		return -1;
	}

	mem = (char *)KERNEL_TEXTADDR;
	func = (void *)KERNEL_TEXTADDR;
	printf("NetBSD kernel loading.");
	c = 0;
	do {
		size = read(fd, mem, 0x4000);
		mem = &mem[0x4000];
		if((++c & 0x7) == 0) putchar('.');
	} while (size == 0x4000);
	putchar('\r'), putchar('\n');
	close(fd);

	if (turbo_mode)
		hw_config(HW_CONFIG_TURBO, 1, 0);
	sleep(500);
	INT_DISABLE();
	WTCSR_WR = 0xa500;

	memcpy((char *)0x8c000000, ptr, 0x2000);
	(*func)();
	/*NOTREACHED*/
	return 0;
}
Ejemplo n.º 2
0
/** Requested operations */
static int op(bt_vendor_opcode_t opcode, void *param)
{
    int retval = 0;
    int nCnt = 0;
    int nState = -1;

    ALOGV("bt-vendor : op for %d", opcode);

    switch(opcode)
    {
        case BT_VND_OP_POWER_CTRL:
            {
                nState = *(int *) param;
                retval = hw_config(nState);
                if(nState == BT_VND_PWR_ON
                   && retval == 0
                   && is_hw_ready() == TRUE){
                    retval = 0;
                }
                else {
                    retval = -1;
                }
            }
            break;

        case BT_VND_OP_FW_CFG:
            {
                // call hciattach to initalize the stack
                if(bt_vendor_cbacks){
                   ALOGI("Bluetooth Firmware and smd is initialized");
                   bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_SUCCESS);
                }
                else{
                   ALOGE("Error : hci, smd initialization Error");
                   bt_vendor_cbacks->fwcfg_cb(BT_VND_OP_RESULT_FAIL);
                }
            }
            break;

        case BT_VND_OP_SCO_CFG:
            {
                bt_vendor_cbacks->scocfg_cb(BT_VND_OP_RESULT_SUCCESS); //dummy
            }
            break;

        case BT_VND_OP_USERIAL_OPEN:
            {
                if(bt_hci_init_transport(pFd) != -1){
                    int (*fd_array)[] = (int (*) []) param;

                        (*fd_array)[CH_CMD] = pFd[0];
                        (*fd_array)[CH_EVT] = pFd[0];
                        (*fd_array)[CH_ACL_OUT] = pFd[1];
                        (*fd_array)[CH_ACL_IN] = pFd[1];
                }
                else {
                    retval = -1;
                    break;
                }
                retval = 2;
            }
            break;

        case BT_VND_OP_USERIAL_CLOSE:
            {
                 bt_hci_deinit_transport(pFd);
            }
            break;

        case BT_VND_OP_GET_LPM_IDLE_TIMEOUT:
            break;

        case BT_VND_OP_LPM_SET_MODE:
            {
                bt_vendor_cbacks->lpm_cb(BT_VND_OP_RESULT_SUCCESS); //dummy
            }
            break;

        case BT_VND_OP_LPM_WAKE_SET_STATE:
            break;
        case BT_VND_OP_EPILOG:
            {
#if (HW_NEED_END_WITH_HCI_RESET == FALSE)
                if (bt_vendor_cbacks)
                {
                    bt_vendor_cbacks->epilog_cb(BT_VND_OP_RESULT_SUCCESS);
                }
#else
                hw_epilog_process();
#endif
            }
            break;
    }

    return retval;
}
Ejemplo n.º 3
0
static void gf_timer_work(struct work_struct *work)
{
    unsigned char value[4] = { 0 };
    unsigned char* p_fw = GF_FW;
    struct gf_dev *gf_dev = NULL;
    int ret = 0;
    u8 mode = 0xFF;

    GF_LOG_INFO("start\n");
    if (work == NULL) {
		GF_LOG_INFO("wrong work\n");
		return;
    }
    gf_dev = container_of(work, struct gf_dev, spi_work);

    if(gf_dev->mode == GF_FF_MODE)
		goto exit;

    mutex_lock(&gf_dev->buf_lock);
    gf_dev->spi->max_speed_hz = 960000;//SPI_SPEED_MIN;
    spi_setup(gf_dev->spi);
    mutex_unlock(&gf_dev->buf_lock);

    gf_spi_read_byte(gf_dev, 0x8040, &value[0]);
    gf_spi_read_byte(gf_dev, 0x8000, &value[1]);
    gf_spi_read_byte(gf_dev, 0x8043, &value[2]);

    if (value[0] == 0xC6 && value[1] == 0x47) {
		gf_spi_write_byte(gf_dev, 0x8040, 0xAA);
		mdelay(1);
    } else {
		gf_spi_read_byte(gf_dev, 0x8040, &value[0]);
		gf_spi_read_byte(gf_dev, 0x8000, &value[1]);
		gf_spi_read_byte(gf_dev, 0x8043, &value[2]);
		if ((value[0] == 0xC6) && (value[1] == 0x47)) {
		    gf_spi_write_byte(gf_dev, 0x8040, 0xAA);
		    mdelay(1);
		} else {
		    GF_LOG_INFO("hardware works abnormal,do reset! 0x8040 = 0x%x \
				0x8000 = 0x%x 0x8046 = 0x%x\n", value[0], value[1], value[2]);
			gf_irq_disable(gf_dev);
		    gf_reset(gf_dev);

		    gf_spi_read_byte(gf_dev, 0x41e4, &value[0]);
		    gf_spi_read_byte(gf_dev, 0x8000, &value[1]);
		    GF_LOG_INFO("read 0x41e4 finish value = 0x%x, 0x8000=0x%x\n",
				value[0], value[1]);

		    if (value[0] != 0xbe) {
				gf_spi_read_byte(gf_dev, 0x41e4, &value[0]);
				if (value[0] != 0xbe) {
				    /*******************firmware update*********************/
				    GF_LOG_INFO("firmware update start\n");
				    del_timer_sync(&gf_dev->gf_timer);
				    if (gf_fw_update_init(gf_dev)) {
						gf_fw_update(gf_dev, p_fw, FW_LENGTH);
						gf_reset();
				    }
				    gf_dev->gf_timer.expires = jiffies + 2 * HZ;
				    add_timer(&gf_dev->gf_timer);
				}
		    }
		    /**********************update config*************************/
		    ret = gf_spi_write_byte(gf_dev, 0x8040, 0xAA);
		    if (!ret)
				GF_LOG_INFO("write 0x8040 fail\n");

		    if (!hw_config(gf_dev))
				GF_LOG_INFO("write config fail\n");
		    gf_irq_enable(gf_dev);
		}
    }
    /* if mode was changed by reset, we should set the mode  back to the primary mode */
    gf_spi_read_byte(gf_dev, GF_MODE_STATUS, &mode);
    if (mode != gf_dev->mode) {
		GF_LOG_INFO("set mode back\n");
		gf_spi_write_byte(gf_dev, GF_MODE_STATUS, gf_dev->mode);
		gf_spi_read_byte(gf_dev, GF_MODE_STATUS, &mode);
		GF_LOG_INFO("mode444 = %d\n", mode);
    }

exit:
    mod_timer(&gf_dev->gf_timer, jiffies + 2*HZ);
    GF_LOG_INFO("end\n");
}