示例#1
0
static int isp_regulator_init(struct device_node *fdt_node, struct isp_regulators *ir)
{
    const char *avdd_src = NULL;

/*DVDD*/
    struct dts_gpio *dvdd_gpio = &ir->dvdd_gpio;
    DBG_INFO("");
    if (!gpio_init(fdt_node, "dvdd-gpios", dvdd_gpio, 0))/* poweroff */
        ir->dvdd_use_gpio = 1;
    else
        ir->dvdd_use_gpio = 0;

    if (regulator_init(fdt_node, "dvdd-regulator",
                "dvdd-regulator-scope", &ir->dvdd))
        goto fail;

/*AVDD*/
    if (of_property_read_string(fdt_node, "avdd-src", &avdd_src)) {
        DBG_ERR("get avdd-src faild");
        goto fail;
    }

    if (!strcmp(avdd_src, "regulator")) {
        DBG_INFO("avdd using regulator");
        ir->avdd_use_gpio = 0;

        if (regulator_init(fdt_node, "avdd-regulator",
                    "avdd-regulator-scope", &ir->avdd.regul))
            goto free_dvdd;
    } else if (!strcmp(avdd_src, "gpio")) {
        struct dts_gpio *gpio = &ir->avdd.gpio;
        ir->avdd_use_gpio = 1;

        if (gpio_init(fdt_node, "avdd-gpios", gpio, 0))/* poweroff */
            goto fail;

        DBG_INFO("set - avdd gpio value: 0x%x", gpio_get_value(gpio->num));
    } else {
        DBG_INFO("needn't operate avdd manually");
    }

    return 0;

free_dvdd:
    regulator_exit(&ir->dvdd);
fail:
    return -1;
}
示例#2
0
void __init msm_acpu_clock_init(struct msm_acpu_clock_platform_data *clkdata)
{
	int cpu;

	mutex_init(&drv_state.lock);
	drv_state.acpu_switch_time_us = clkdata->acpu_switch_time_us;
	drv_state.vdd_switch_time_us = clkdata->vdd_switch_time_us;
	drv_state.max_speed_delta_khz = clkdata->max_speed_delta_khz;

	/* Configure hardware. */
	regulator_init();
	force_all_to_afab();
	scpll_set_refs();
	for_each_possible_cpu(cpu)
		scpll_init(cpu);
	scpll_init(L2);

	lpj_init();
	precompute_stepping();

	/* Improve boot time by ramping up CPUs immediately. */
	for_each_online_cpu(cpu)
		acpuclk_set_rate(cpu, 1080000, SETRATE_CPUFREQ);

	cpufreq_table_init();
}
示例#3
0
int main(void)
{

    bus_init(BUS_ADDRESS_CHASSIS);
    _delay_ms(100);
    engine_init();
    regulator_init();

    carrying_rfid = 0;
    handled_count = 0;
    manual_control = 0;
    scan_count = 0;
    lap_finished = 0;
    number_of_stations = 0;
    station_count = 0;

    // bus_register_receive(1, receive_line_data);
    bus_register_receive(2, arm_is_done);
    bus_register_receive(3, control_line_following);
    bus_register_receive(4, RFID_done);
    bus_register_receive(8, engine_control_command);
    bus_register_receive(11, engine_set_kp);
    bus_register_receive(12, engine_set_kd);

    sei();
    start_button_init();
    timer_interrupt_init();

    while(1)
    {

    }
}
示例#4
0
int board_early_init_r(void)
{
#ifdef CONFIG_REGULATOR
	regulator_init();
#endif
#ifdef CONFIG_JZ_GPIO
	gpio_init();
#endif
	return 0;
}
示例#5
0
文件: main.c 项目: mokis/MServo
int main (void)
{
	// Configure pins to the default states.
	config_pin_defaults();

    // Initialize the watchdog module.
    watchdog_init();

    // First, initialize registers that control servo operation.
    registers_init();

    // Initialize the PWM module.
    pwm_init();

    // Initialize the ADC module.
    adc_init();

#if ESTIMATOR_ENABLED
    // Initialize the state estimator module.
    estimator_init();
#endif

#if REGULATOR_MOTION_ENABLED
    // Initialize the regulator algorithm module.
    regulator_init();
#endif

#if PID_MOTION_ENABLED
    // Initialize the PID algorithm module.
    pid_init();
#endif

#if IPD_MOTION_ENABLED
    // Initialize the IPD algorithm module.
    ipd_init();
#endif

#if CURVE_MOTION_ENABLED
    // Initialize curve motion module.
    motion_init();
#endif

    // Initialize the power module.
    power_init();

#if PULSE_CONTROL_ENABLED
    pulse_control_init();
#endif

    // Initialize the TWI slave module.
    twi_slave_init(registers_read_byte(REG_TWI_ADDRESS));

    // Finally initialize the timer.
    timer_set(0);

    // Enable interrupts.
    sei();

    // Wait until initial position value is ready.
    while (!adc_position_value_is_ready());

#if CURVE_MOTION_ENABLED
    // Reset the curve motion with the current position of the servo.
    motion_reset(adc_get_position_value());
#endif

    // Set the initial seek position and velocity.
    registers_write_word(REG_SEEK_POSITION_HI, REG_SEEK_POSITION_LO, adc_get_position_value());
    registers_write_word(REG_SEEK_VELOCITY_HI, REG_SEEK_VELOCITY_LO, 0);

    // XXX Enable PWM and writing.  I do this for now to make development and
    // XXX tuning a bit easier.  Constantly manually setting these values to 
    // XXX turn the servo on and write the gain values get's to be a pain.
    pwm_enable();
    registers_write_enable();

    // This is the main processing loop for the servo.  It basically looks
    // for new position, power or TWI commands to be processed.
    for (;;)
    {
        // Is position value ready?
        if (adc_position_value_is_ready())
        {
            int16_t pwm;
            int16_t position;

#if PULSE_CONTROL_ENABLED
            // Give pulse control a chance to update the seek position.
            pulse_control_update();
#endif

#if CURVE_MOTION_ENABLED
            // Give the motion curve a chance to update the seek position and velocity.
            motion_next(10);
#endif

            // Get the new position value.
            position = (int16_t) adc_get_position_value();

#if ESTIMATOR_ENABLED
            // Estimate velocity.
            estimate_velocity(position);
#endif

#if PID_MOTION_ENABLED
            // Call the PID algorithm module to get a new PWM value.
            pwm = pid_position_to_pwm(position);
#endif

#if IPD_MOTION_ENABLED
            // Call the IPD algorithm module to get a new PWM value.
            pwm = ipd_position_to_pwm(position);
#endif

#if REGULATOR_MOTION_ENABLED
            // Call the state regulator algorithm module to get a new PWM value.
            pwm = regulator_position_to_pwm(position);
#endif

            // Update the servo movement as indicated by the PWM value.
            // Sanity checks are performed against the position value.
            pwm_update(position, pwm);
        }

        // Is a power value ready?
        if (adc_power_value_is_ready())
        {
            // Get the new power value.
            uint16_t power = adc_get_power_value();

            // Update the power value for reporting.
            power_update(power);
        }

        // Was a command recieved?
        if (twi_data_in_receive_buffer())
        {
            // Handle any TWI command.
            handle_twi_command();
        }

#if MAIN_MOTION_TEST_ENABLED
        // This code is in place for having the servo drive itself between 
        // two positions to aid in the servo tuning process.  This code 
        // should normally be disabled in config.h.
#if CURVE_MOTION_ENABLED
        if (motion_time_left() == 0)
        {
            registers_write_word(REG_CURVE_DELTA_HI, REG_CURVE_DELTA_LO, 2000);
            registers_write_word(REG_CURVE_POSITION_HI, REG_CURVE_POSITION_LO, 0x0100);
            motion_append();
            registers_write_word(REG_CURVE_DELTA_HI, REG_CURVE_DELTA_LO, 1000);
            registers_write_word(REG_CURVE_POSITION_HI, REG_CURVE_POSITION_LO, 0x0300);
            motion_append();
            registers_write_word(REG_CURVE_DELTA_HI, REG_CURVE_DELTA_LO, 2000);
            registers_write_word(REG_CURVE_POSITION_HI, REG_CURVE_POSITION_LO, 0x0300);
            motion_append();
            registers_write_word(REG_CURVE_DELTA_HI, REG_CURVE_DELTA_LO, 1000);
            registers_write_word(REG_CURVE_POSITION_HI, REG_CURVE_POSITION_LO, 0x0100);
            motion_append();
        }
#else
        {
            // Get the timer.
            uint16_t timer = timer_get();

            // Reset the timer if greater than 800.
            if (timer > 800) timer_set(0);

            // Look for specific events.
            if (timer == 0)
            {
                registers_write_word(REG_SEEK_HI, REG_SEEK_LO, 0x0100);
            }
            else if (timer == 400)
            {
                registers_write_word(REG_SEEK_HI, REG_SEEK_LO, 0x0300);
            }
        }
#endif
#endif
    }

    return 0;
}
示例#6
0
static void __init cpcap_of_init(void)
{
	int size, unit_size, i, count;
	struct device_node *node;
	const void *prop;
	struct device_node *bp_node;
	const void *bp_prop;
	char *cpcap_bp_model = "CDMA";
	
	static struct omap_spi_init_entry cpcap_spiinit_data[] = {  
		{CPCAP_REG_SDVSPLL,  0xDB04}, 
		{CPCAP_REG_S4C1, 0x4034},
		{CPCAP_REG_S4C2,  0x3434},
         {CPCAP_REG_MDLC,  0x0000}   } ;
	static struct omap_rgt_init_entry cpcap_reginitmode_data[] = {  
          {CPCAP_VCSI,     1800000,    1800000,    0x8,    0x00,    0x01,     0x01},
          {CPCAP_VDIG,    1875000,    1875000,    0x1,    0x01,    0x00,    0x01},
          {CPCAP_VRF1,    2775000,    2775000,    0x9,    0x01,    0x00,    0x01},
          {CPCAP_VRF2,    2775000,    2775000,    0x9,    0x01,    0x00,    0x01},
          {CPCAP_VRFREF,    2775000,    2775000,    0x9,    0x01,    0x00,    0x01},
          {CPCAP_VSIM,    1800000,    2900000,    0x9,    0x00,    0x00,    0x00},
          {CPCAP_VSIMCARD,    1800000,    2900000,    0x9,    0x00,    0x00,    0x00}  } ;
	static struct omap_rgt_mode_entry cpcap_regmode_data[] = {  
          {CPCAP_VCSI,        0x0043},
          {CPCAP_VDIG,        0x0082},
          {CPCAP_VRF1,        0x0024},
          {CPCAP_VRF2,        0x0001},
          {CPCAP_VRFREF,        0x0023},
          {CPCAP_VAUDIO,      0x0014},
	     {CPCAP_VHVIO,	      0x0012},
	     {CPCAP_VSIM,		0x0022},
	     {CPCAP_VSIMCARD,	0x0480}  } ;			
	static struct omap_rgt_mode_entry cpcap_regoffmode_data[] = {  {CPCAP_VCSI,  0x0041 } };
					
	bp_node = of_find_node_by_path(DT_PATH_CHOSEN);
	if (bp_node) {
		bp_prop = of_get_property(bp_node, DT_PROP_CHOSEN_BP, NULL);
		if (bp_prop)
			cpcap_bp_model = (char *)bp_prop;

		of_node_put(bp_node);
	}

	if (strcmp(cpcap_bp_model, "UMTS") >= 0)
		mapphone_cpcap_data.is_umts = 1;

	count = 4;
	printk(KERN_INFO "cpcap init size = %d\n", count);
	for (i = 0; i < count; i++)
		cpcap_spi_init((struct omap_spi_init_entry *)&cpcap_spiinit_data[i]);

	count = 7;
	printk(KERN_INFO "cpcap init size = %d\n", count);
	for (i = 0; i < count; i++)
		regulator_init((struct omap_rgt_init_entry *)&cpcap_reginitmode_data[i]);

	count = 9;
	printk(KERN_INFO "cpcap init size = %d\n", count);
	for (i = 0; i < count; i++)
		regulator_mode_init((struct omap_rgt_mode_entry *)&cpcap_regmode_data[i]);

	count = 1;
	printk(KERN_INFO "cpcap init size = %d\n", count);
	for (i = 0; i < count; i++)
		regulator_off_mode_init((struct omap_rgt_mode_entry *)&cpcap_regoffmode_data[i]);

	return;
}
示例#7
0
void BSP_DRV_Init()
{
#ifdef CONFIG_MODULE_VIC
    s32 ret = 0;
#endif

/***********************基础模块初始化***************************/
#ifdef CONFIG_BALONG_CCLK
    hi6930_clock_init();
#endif
#ifdef CONFIG_CCORE_PM
		 bsp_dpm_init();
#endif
#ifdef K3_TIMER_FEATURE
	k3_timer_init();
#endif
    adp_timer_init();
    timer_dpm_init();

    if(0 != BSP_UDI_Init())
        logMsg("BSP_UDI_Init fail\n",0,0,0,0,0,0);

    bsp_ipc_init();

	bsp_icc_init();

#ifdef CONFIG_K3V3_CLK_CRG /*CONFIG_K3V3_CLK_CRG*/
    gps_refclk_icc_read_cb_init();
#endif
	/* Cshell init if magic number is set to PRT_FLAG_EN_MAGIC_M */
#ifdef CONFIG_CSHELL
    if(0 != cshell_init())
    {
            logMsg("cshell init fail\n",0,0,0,0,0,0);
    }
#endif

#ifdef CONFIG_NVIM
     if(0 != bsp_nvm_init())
        logMsg("nv init fail\n",0,0,0,0,0,0);
#endif

    /* axi monitor监控初始化 */
    (void)bsp_amon_init();

	/*此初始化必须放置在MSP/OAM/PS初始化之前,请不要随意改动顺序*/
    tcxo_init_configure();

    if(0 != bsp_rfile_init())
        logMsg("rfile init fail\n",0,0,0,0,0,0);

	/* version inits */
    bsp_productinfo_init();

    hwspinlock_init();

    bsp_hkadc_init();

    bsp_version_init();
    bsp_lowpower_mntn_init();

#ifdef CONFIG_MODULE_VIC
    ret = bsp_vic_init();
    if(ret != OK)
    {
        logMsg("bsp_vic_init error\n", 0, 0, 0, 0, 0, 0);
    }
#endif

	(void)bsp_softtimer_init();

#ifdef CONFIG_BALONG_EDMA
    if(0 != bsp_edma_init())
    {
        logMsg("edma init fail \n",0,0,0,0,0,0);
    }
#endif

    /*C core init ipc module*/
    if(0 != socp_init())
        logMsg("socp init fail\n",0,0,0,0,0,0);

     if(0 != bsp_om_server_init())
        logMsg("om init fail\n",0,0,0,0,0,0);
	 if(0 != bsp_dual_modem_init())
	     logMsg("dual modem uart init fail\n",0,0,0,0,0,0);

/***********************外设模块初始化***************************/
    bsp_dsp_init();

#ifdef CONFIG_BBP_INT
	bbp_int_init();/*此处需要放在dsp初始化之后,放在pastar/abb之前*/
#endif

    bsp_spi_init();
    bsp_pmu_init();
	regulator_init();

#if defined(CONFIG_PMIC_HI6559)
    if(bsp_pa_rf_init())   /* 依赖于regulator_init */
    {
        logMsg("bsp_pa_rf_init fail\n",0,0,0,0,0,0);
    }
#endif

	/*init mipi*/
#ifdef CONFIG_MIPI
	bsp_mipi_init();
#endif

#ifdef CONFIG_TUNER
    bsp_tuner_init();
#endif

#ifdef CONFIG_PASTAR
	/*此函数的位置不可以向后移动,为pastar上电后,提供足够的稳定时间*/
    pmu_hi6561_init_phase1();
#endif

     if(0 != hi6930_wdt_init())
        logMsg("wdt init fail\n",0,0,0,0,0,0);

#ifdef CONFIG_CCORE_I2C

	if(0!=bsp_i2c_initial())
		logMsg("i2c init fail\n",0,0,0,0,0,0);
#endif


    if(0 != bsp_gpio_init())
        logMsg("gpio init fail\n",0,0,0,0,0,0);
#ifdef CONFIG_EFUSE
	if(0 != efuse_init())
	{
		logMsg("efuse init fail \n",0,0,0,0,0,0);
    }
#endif

#ifdef CONFIG_LEDS_CCORE
    if(0 != bsp_led_init())
    {
        logMsg("led init fail\n",0,0,0,0,0,0);
    }
#endif

/***********************通信支撑模块初始化***************************/
#ifdef CONFIG_CIPHER
    if(0 != cipher_init())
    {
        logMsg("cipher init fail \n",0,0,0,0,0,0);
    }
	if(0 != bsp_acc_init())
	{
		logMsg("acc init fail \n",0,0,0,0,0,0);
	}
#endif

#ifdef CONFIG_IPF
    if(0 != ipf_init())
        logMsg("ipf init fail\n",0,0,0,0,0,0);
#endif

#ifdef CONFIG_MODULE_BUSSTRESS
	 ipf_ul_stress_test_start(10);
#endif

#ifdef FEATURE_TLPHY_MAILBOX
    bsp_mailbox_init();
#endif

    mailbox_init();

#ifdef CONFIG_ANTEN
    if(0 != bsp_anten_init())
        logMsg("anten init fail.\n",0,0,0,0,0,0);
#endif

	bsp_sci_cfg_init();

    bsp_abb_init();

    bsp_on_off_init();

	cpufreq_init();

    /*初始化醒来的时间戳*/
    update_awake_time_stamp();

#ifdef CONFIG_CCORE_BALONG_PM
    balong_pm_init();
#endif

#ifdef CONFIG_AUDIO
    audio_init();
#endif

#ifdef CONFIG_BALONG_MODEM_RESET
	bsp_reset_init();
#endif

    (void)bsp_rf_rse_init();
#ifdef CONFIG_PASTAR
	/*勿动!此处需要放置在该函数最后,确保pastar上电后稳定后,进行初始化配置*/
	pmu_hi6561_init_phase2();
#endif

	(void)bsp_antn_sw_init();

}
示例#8
0
int LDO_Init(void)
{
	return regulator_init();
}