static void dump_mdm_related_gpio(void) { dump_gpio("AP2MDM_STATUS", mdm_drv->ap2mdm_status_gpio); dump_gpio("AP2MDM_ERRFATAL", mdm_drv->ap2mdm_errfatal_gpio); dump_gpio("AP2MDM_PMIC_RESET_N", mdm_drv->ap2mdm_pmic_reset_n_gpio); dump_gpio("MDM2AP_STATUS", mdm_drv->mdm2ap_status_gpio); dump_gpio("MDM2AP_ERRFATAL", mdm_drv->mdm2ap_errfatal_gpio); return; }
void handle_debug(void) { static unsigned char __pdata my_game_key_status[2]; /* does current state of this bit differ from the state that was last seen */ if( (cursors.game_key_status[0] ^ my_game_key_status[0]) & 0x02 ) { /* track that bit */ my_game_key_status[0] ^= 0x02; if( my_game_key_status[0] & 0x02) { dump_mcs51(); dump_xdata_sfr(); } cursors.keycode_updated = 0; // hack } /* does current state of this bit differ from the state that was last seen */ if( (cursors.game_key_status[0] ^ my_game_key_status[0]) & 0x04 ) { /* track that bit */ my_game_key_status[0] ^= 0x04; if( my_game_key_status[0] & 0x04) { dump_gpio(); } cursors.keycode_updated = 0; // hack } }
const ff_gpio* setup_gpio(gpio_port port, gpio_pin pin) { init(); void *map = mmap( NULL, SZ_64K, // Map length // Enable reading & writting to mapped memory PROT_READ | PROT_WRITE, MAP_SHARED, // Shared with other processes mem_fd, // File to map // Offset to GPIO peripheral 0xFF780000 + port * SZ_64K ); if (map == MAP_FAILED) { printf("mmap error %d\n", (unsigned)map); exit(EXIT_FAILURE); } ff_gpio *gpio = malloc(sizeof(ff_gpio)); gpio->port = port; gpio->pin = pin; gpio->bit = (0x1 << pin); gpio->address = (volatile unsigned *)map; dump_gpio(setup, gpio); return gpio; }
int main(int argc, char **args) { const ff_gpio *gpio = setup_gpio(GPIO7, A3); dump_gpio(main, gpio); blink(gpio); close(mem_fd); if (gpio->address != NULL) free(gpio->address); free(gpio); return 0; }
static void dump_mdm_related_gpio(void) { dump_gpio("AP2MDM_STATUS", mdm_drv->ap2mdm_status_gpio); /* charm_dump_GPIO("AP2MDM_WAKEUP", mdm_drv->ap2mdm_wakeup_gpio); */ dump_gpio("AP2MDM_ERRFATAL", mdm_drv->ap2mdm_errfatal_gpio); dump_gpio("AP2MDM_PMIC_RESET_N", mdm_drv->ap2mdm_pmic_reset_n_gpio); dump_gpio("MDM2AP_STATUS", mdm_drv->mdm2ap_status_gpio); /* charm_dump_GPIO("MDM2AP_WAKEUP", mdm_drv->mdm2ap_wakeup_gpio); */ dump_gpio("MDM2AP_ERRFATAL", mdm_drv->mdm2ap_errfatal_gpio); dump_gpio("MDM2AP_WAKEUP", mdm_drv->mdm2ap_wakeup_gpio); dump_gpio("AP2MDM_SW_BC5", mdm_drv->ap2mdm_sw_bc5_gpio); return; }
void gpio_as_dmic(void) { /* dmic 0, PB21,PB22, func 0*/ REG_GPIO_PXINTC(1) |= 3 << 21; REG_GPIO_PXMASKC(1) |= 3 << 21; REG_GPIO_PXPAT1C(1) |= 3 << 21; REG_GPIO_PXPAT0C(1) |= 3 << 21; /* dmic 1, PB05 func 1*/ REG_GPIO_PXINTC(1) |= 1 << 5; REG_GPIO_PXMASKC(1) |= 1 << 5; REG_GPIO_PXPAT1C(1) |= 1 << 5; REG_GPIO_PXPAT0S(1) |= 1 << 5; #ifdef DMIC_VOICE_DEBUG dump_gpio(); #endif }
long mdm_modem_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int status, ret = 0; if (_IOC_TYPE(cmd) != CHARM_CODE) { pr_err("%s: invalid ioctl code\n", __func__); return -EINVAL; } pr_debug("%s: Entering ioctl cmd = %d\n", __func__, _IOC_NR(cmd)); switch (cmd) { case WAKE_CHARM: pr_info("%s: Powering on mdm\n", __func__); mdm_drv->mdm_ready = 0; mdm_drv->mdm_hsic_reconnectd = 0; mdm_drv->ops->power_on_mdm_cb(mdm_drv); break; case CHECK_FOR_BOOT: if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0) put_user(1, (unsigned long __user *) arg); else put_user(0, (unsigned long __user *) arg); break; case NORMAL_BOOT_DONE: { int ret_mdm_hsic_reconnectd = 0; pr_debug("%s: check if mdm is booted up\n", __func__); get_user(status, (unsigned long __user *) arg); if (status) { pr_debug("%s: normal boot failed\n", __func__); mdm_drv->mdm_boot_status = -EIO; } else { pr_info("%s: normal boot done\n", __func__); mdm_drv->mdm_boot_status = 0; } mdm_status_change_notified = false; queue_work_on(0, mdm_gpio_monitor_queue, &mdm_status_check_work); mdm_drv->mdm_ready = 1; if (mdm_drv->ops->normal_boot_done_cb != NULL) mdm_drv->ops->normal_boot_done_cb(mdm_drv); ret_mdm_hsic_reconnectd = mdm_hsic_reconnectd_check_fn(); if ( ret_mdm_hsic_reconnectd == 1 ) { pr_info("%s: ret_mdm_hsic_reconnectd == 1\n", __func__); } else { pr_info("%s: ret_mdm_hsic_reconnectd == 0\n", __func__); } if (!first_boot) complete(&mdm_boot); else first_boot = 0; } break; case RAM_DUMP_DONE: pr_debug("%s: mdm done collecting RAM dumps\n", __func__); get_user(status, (unsigned long __user *) arg); if (status) mdm_drv->mdm_ram_dump_status = -EIO; else { pr_info("%s: ramdump collection completed\n", __func__); mdm_drv->mdm_ram_dump_status = 0; } complete(&mdm_ram_dumps); break; case WAIT_FOR_RESTART: pr_debug("%s: wait for mdm to need images reloaded\n", __func__); if (mdm_drv) { dump_gpio("MDM2AP_STATUS", mdm_drv->mdm2ap_status_gpio); dump_gpio("MDM2AP_ERRFATAL", mdm_drv->mdm2ap_errfatal_gpio); } ret = wait_for_completion_interruptible(&mdm_needs_reload); if (!ret) { put_user(mdm_drv->boot_type, (unsigned long __user *) arg); pr_err("%s: mdm_drv->boot_type:%d\n", __func__, mdm_drv->boot_type); } INIT_COMPLETION(mdm_needs_reload); break; case GET_MFG_MODE: pr_info("%s: board_mfg_mode()=%d\n", __func__, board_mfg_mode()); put_user(board_mfg_mode(), (unsigned long __user *) arg); break; case SET_MODEM_ERRMSG: pr_info("%s: Set modem fatal errmsg\n", __func__); ret = set_mdm_errmsg((void __user *) arg); break; case GET_RADIO_FLAG: pr_info("%s:get_radio_flag()=%x\n", __func__, get_radio_flag()); put_user(get_radio_flag(), (unsigned long __user *) arg); break; case EFS_SYNC_DONE: pr_info("%s: efs sync is done\n", __func__); break; case NV_WRITE_DONE: pr_info("%s: NV write done!\n", __func__); notify_mdm_nv_write_done(); break; default: pr_err("%s: invalid ioctl cmd = %d\n", __func__, _IOC_NR(cmd)); ret = -EINVAL; break; } return ret; }
//! You expected it: This routine is expected never to exit void main (void) { port_init(); watchdog_init(); timer_gpt3_init(); adc_init(); cursors_init(); power_init(); uart_init(); /* enable interrupts. */ EA = 1; get_board_id(); startup_message(); dump_xdata_sfr(); gpio_check_IO_direction(); dump_gpio(); dump_mcs51(); tx_drain(); // oops, UART routines seem not yet clean print_states_ruler(); print_states_enable = 1; print_states(); print_states_enable = 0; save_old_states(); states.number = 0; manufacturing_print_all(); ow_init(); timer1_init(); battery_charging_table_init(); LED_CHG_G_OFF(); LED_CHG_R_OFF(); LED_PWR_OFF(); /* The main loop contains several state machines handling various subsystems on the EC. The idea is to have each subroutine return as quickly as it can (no busy wait unless for a _very_ short delay). Also the subroutines should be pretty much self contained. Unless it is noted _here_ no state machine should need more than xxx microseconds before returning control. When a state machine returns control it is expected to have the variables it is working on in a consistent state. Period (just in case it was missed:^) If it helps: you may want to think of the main loop as a round-robin cooperative scheduler without the overhead this usually implies. This works well if, well, if _all_ routines within the main loop cooperate well. */ while(1) { STATES_TIMESTAMP(); busy = handle_command(); busy |= handle_cursors(); handle_leds(); handle_power(); handle_ds2756_requests(); handle_ds2756_readout(); busy |= handle_battery_charging_table(); watchdog_all_up_and_well |= WATCHDOG_MAIN_LOOP_IS_FINE; print_states(); monitor(); handle_debug(); sleep_if_allowed(); } }