mx53 and mc34708 wakeup

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mx53 and mc34708 wakeup

1,004 Views
alexeym
Contributor III

Hello all,


I've got custom mx53 board based on mx53 loco with mc34708 power and last 2.6.35 kernel from freescale git.

My MC34708  PMIC_INT connected to CSI0_DAT10 and muxed as gpio 5_28.

How to get power button to work?

AFAIK TZIC workaround needs to be used only for da9053 boards.

Some code below:

#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)

#define GPIO_BUTTON(gpio_num, ev_code, act_low, descr, wake) \

{ \

  .gpio = gpio_num, \

  .type = EV_KEY, \

  .code = ev_code, \

  .active_low = act_low, \

  .desc = "btn " descr, \

  .wakeup = wake, \

}

static struct gpio_keys_button loco_buttons[] = {

  GPIO_BUTTON(MX53_nONKEY, KEY_POWER, 1, "power", 0),

};

static struct gpio_keys_platform_data loco_button_data = {

  .buttons = loco_buttons,

  .nbuttons = ARRAY_SIZE(loco_buttons),

};

static struct platform_device loco_button_device = {

  .name = "gpio-keys",

  .id = -1,

  .num_resources  = 0,

  .dev = {

  .platform_data = &loco_button_data,

  }

};

static void __init loco_add_device_buttons(void)

{

  platform_device_register(&loco_button_device);

}

#else

static void __init loco_add_device_buttons(void) {}

#endif

static void mxc_register_powerkey(pwrkey_callback pk_cb)

{

  pmic_event_callback_t power_key_event;

   power_key_event.param = (void *)1;

  power_key_event.func = (void *)pk_cb;

  pmic_event_subscribe(EVENT_PWRONI, power_key_event);

}

static int mxc_pwrkey_getstatus(int id)

{

  int sense;

  pmic_read_reg(REG_INT_SENSE1, &sense, 0xffffffff);

  if (sense & (1 << 3))

       return 0;

  return 1;

}

static struct power_key_platform_data pwrkey_data = {

  .key_value = KEY_F4,

  .register_pwrkey = mxc_register_powerkey,

  .get_key_status = mxc_pwrkey_getstatus,

};

//-------- init

mc34708_int = MX53_PAD_CSI0_DAT10__GPIO5_28;

  mx53_loco_mc34708_irq = (4*32 + 28);

mxc_iomux_v3_setup_pad(mc34708_int);

  gpio_request(mx53_loco_mc34708_irq, "pmic-int");

  gpio_direction_input(mx53_loco_mc34708_irq);

  mx53_loco_init_mc34708(mx53_loco_mc34708_irq);

  dvfs_core_data.reg_id = "SW1A";

  tve_data.dac_reg = "VDAC";

  bus_freq_data.gp_reg_id = "SW1A";

  bus_freq_data.lp_reg_id = "SW2";

  mxc_register_device(&mxc_powerkey_device, &pwrkey_data);

  mxc_register_device(&pm_device, &loco_pm_data);

  loco_add_device_buttons();

I can wakeup board thru USB, but cannot use button.

I even can't check gpio thru terminal:

echo 156 > sys/class/gpio/export

-bash: echo: write error: Device or resource busy

What's wrong with my configuration?

Labels (2)
0 Kudos
2 Replies

486 Views
alexeym
Contributor III

Sorry, that was hardware problem, everything works fine. Thanks for your help anyway!

0 Kudos

486 Views
weidong_sun
NXP TechSupport
NXP TechSupport

hello,alexeym,

      I did it based on mc34708+i.mx53, please add the following:

/*Maybe you have these 4 lines in your BSP*/

#define TZIC_WAKEUP0_OFFSET         (0x0E00)

#define TZIC_WAKEUP1_OFFSET         (0x0E04)

#define TZIC_WAKEUP2_OFFSET         (0x0E08)

#define TZIC_WAKEUP3_OFFSET         (0x0E0C)

/*Use GPIO1_8 to control wakeup and sleep*/

#define GPIO1_8_18_IRQ_BIT   (0x1<<18)

....

/*Following code should be adjusted*/

static void pad_tzic_irq_wakeup(void)
{
void __iomem *tzic_base;
tzic_base = ioremap(MX53_TZIC_BASE_ADDR, SZ_4K);
if (NULL == tzic_base) {
  pr_err("fail to map MX53_TZIC_BASE_ADDR\n");
  return;
}
__raw_writel(0, tzic_base + TZIC_WAKEUP0_OFFSET);
__raw_writel(0, tzic_base + TZIC_WAKEUP2_OFFSET);
__raw_writel(0, tzic_base + TZIC_WAKEUP3_OFFSET);

__raw_writel(GPIO1_8_18_IRQ_BIT, tzic_base + TZIC_WAKEUP1_OFFSET);
iounmap(tzic_base);
pr_info("TZIC irq is wakeup-enabled\n");
}

static void pad_suspend_enter(void)
{
pad_tzic_irq_wakeup();
}

static void pad_suspend_exit(void)
{

/*add your suppend exit code*/
printk(KERN_INFO "GPIO1_8 irq is to wakeup system\n");
}

static struct mxc_pm_platform_data pad_pm_data = {
.suspend_enter = pad_suspend_enter,
.suspend_exit = pad_suspend_exit,
};

....

/*following is your above code */

.....

.....

<Note: accroding to reference manul ,the interrupt number of GPIO_1 signal0~signal15 is 50, we can calculate wakeup bit in TZIC, see page 4622, 32x1+18 = 50, so we can find wakeup bit : No.18 bit in WAKEUP1 register. >

   See attachment, for you as a reference. But you should notice that you can't clear wakeup source of USB. In my code ,I cleaned it.

Weidong

0 Kudos