Lines Matching refs:pad
219 struct pmic_gpio_pad *pad, unsigned int addr) in pmic_gpio_read() argument
224 ret = regmap_read(state->map, pad->base + addr, &val); in pmic_gpio_read()
234 struct pmic_gpio_pad *pad, unsigned int addr, in pmic_gpio_write() argument
239 ret = regmap_write(state->map, pad->base + addr, val); in pmic_gpio_write()
299 struct pmic_gpio_pad *pad; in pmic_gpio_set_mux() local
308 pad = pctldev->desc->pins[pin].drv_data; in pmic_gpio_set_mux()
313 if (!pad->lv_mv_type) { in pmic_gpio_set_mux()
324 pad->function = function; in pmic_gpio_set_mux()
326 if (pad->analog_pass) in pmic_gpio_set_mux()
328 else if (pad->output_enabled && pad->input_enabled) in pmic_gpio_set_mux()
330 else if (pad->output_enabled) in pmic_gpio_set_mux()
335 if (pad->lv_mv_type) { in pmic_gpio_set_mux()
336 ret = pmic_gpio_write(state, pad, in pmic_gpio_set_mux()
341 val = pad->atest - 1; in pmic_gpio_set_mux()
342 ret = pmic_gpio_write(state, pad, in pmic_gpio_set_mux()
347 val = pad->out_value in pmic_gpio_set_mux()
349 val |= pad->function in pmic_gpio_set_mux()
351 ret = pmic_gpio_write(state, pad, in pmic_gpio_set_mux()
357 val |= pad->function << PMIC_GPIO_REG_MODE_FUNCTION_SHIFT; in pmic_gpio_set_mux()
358 val |= pad->out_value & PMIC_GPIO_REG_MODE_VALUE_SHIFT; in pmic_gpio_set_mux()
360 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_MODE_CTL, val); in pmic_gpio_set_mux()
365 val = pad->is_enabled << PMIC_GPIO_REG_MASTER_EN_SHIFT; in pmic_gpio_set_mux()
367 return pmic_gpio_write(state, pad, PMIC_GPIO_REG_EN_CTL, val); in pmic_gpio_set_mux()
381 struct pmic_gpio_pad *pad; in pmic_gpio_config_get() local
384 pad = pctldev->desc->pins[pin].drv_data; in pmic_gpio_config_get()
388 if (pad->buffer_type != PMIC_GPIO_OUT_BUF_CMOS) in pmic_gpio_config_get()
393 if (pad->buffer_type != PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS) in pmic_gpio_config_get()
398 if (pad->buffer_type != PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS) in pmic_gpio_config_get()
403 if (pad->pullup != PMIC_GPIO_PULL_DOWN) in pmic_gpio_config_get()
408 if (pad->pullup != PMIC_GPIO_PULL_DISABLE) in pmic_gpio_config_get()
413 if (pad->pullup != PMIC_GPIO_PULL_UP_30) in pmic_gpio_config_get()
418 if (pad->is_enabled) in pmic_gpio_config_get()
423 arg = pad->power_source; in pmic_gpio_config_get()
426 if (!pad->input_enabled) in pmic_gpio_config_get()
431 arg = pad->output_enabled; in pmic_gpio_config_get()
434 arg = pad->out_value; in pmic_gpio_config_get()
437 arg = pad->pullup; in pmic_gpio_config_get()
440 arg = pad->strength; in pmic_gpio_config_get()
443 arg = pad->atest; in pmic_gpio_config_get()
446 arg = pad->analog_pass; in pmic_gpio_config_get()
449 arg = pad->dtest_buffer; in pmic_gpio_config_get()
463 struct pmic_gpio_pad *pad; in pmic_gpio_config_set() local
468 pad = pctldev->desc->pins[pin].drv_data; in pmic_gpio_config_set()
470 pad->is_enabled = true; in pmic_gpio_config_set()
477 pad->buffer_type = PMIC_GPIO_OUT_BUF_CMOS; in pmic_gpio_config_set()
480 if (!pad->have_buffer) in pmic_gpio_config_set()
482 pad->buffer_type = PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS; in pmic_gpio_config_set()
485 if (!pad->have_buffer) in pmic_gpio_config_set()
487 pad->buffer_type = PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS; in pmic_gpio_config_set()
490 pad->pullup = PMIC_GPIO_PULL_DISABLE; in pmic_gpio_config_set()
493 pad->pullup = PMIC_GPIO_PULL_UP_30; in pmic_gpio_config_set()
497 pad->pullup = PMIC_GPIO_PULL_DOWN; in pmic_gpio_config_set()
499 pad->pullup = PMIC_GPIO_PULL_DISABLE; in pmic_gpio_config_set()
502 pad->is_enabled = false; in pmic_gpio_config_set()
505 if (arg >= pad->num_sources) in pmic_gpio_config_set()
507 pad->power_source = arg; in pmic_gpio_config_set()
510 pad->input_enabled = arg ? true : false; in pmic_gpio_config_set()
513 pad->output_enabled = arg ? true : false; in pmic_gpio_config_set()
516 pad->output_enabled = true; in pmic_gpio_config_set()
517 pad->out_value = arg; in pmic_gpio_config_set()
522 pad->pullup = arg; in pmic_gpio_config_set()
527 pad->strength = arg; in pmic_gpio_config_set()
530 if (!pad->lv_mv_type || arg > 4) in pmic_gpio_config_set()
532 pad->atest = arg; in pmic_gpio_config_set()
535 if (!pad->lv_mv_type) in pmic_gpio_config_set()
537 pad->analog_pass = true; in pmic_gpio_config_set()
542 pad->dtest_buffer = arg; in pmic_gpio_config_set()
549 val = pad->power_source << PMIC_GPIO_REG_VIN_SHIFT; in pmic_gpio_config_set()
551 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_VIN_CTL, val); in pmic_gpio_config_set()
555 val = pad->pullup << PMIC_GPIO_REG_PULL_SHIFT; in pmic_gpio_config_set()
557 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_PULL_CTL, val); in pmic_gpio_config_set()
561 val = pad->buffer_type << PMIC_GPIO_REG_OUT_TYPE_SHIFT; in pmic_gpio_config_set()
562 val |= pad->strength << PMIC_GPIO_REG_OUT_STRENGTH_SHIFT; in pmic_gpio_config_set()
564 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_OUT_CTL, val); in pmic_gpio_config_set()
568 if (pad->dtest_buffer == 0) { in pmic_gpio_config_set()
571 if (pad->lv_mv_type) { in pmic_gpio_config_set()
572 val = pad->dtest_buffer - 1; in pmic_gpio_config_set()
575 val = BIT(pad->dtest_buffer - 1); in pmic_gpio_config_set()
578 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_IN_CTL, val); in pmic_gpio_config_set()
582 if (pad->analog_pass) in pmic_gpio_config_set()
584 else if (pad->output_enabled && pad->input_enabled) in pmic_gpio_config_set()
586 else if (pad->output_enabled) in pmic_gpio_config_set()
591 if (pad->lv_mv_type) { in pmic_gpio_config_set()
592 ret = pmic_gpio_write(state, pad, in pmic_gpio_config_set()
597 val = pad->atest - 1; in pmic_gpio_config_set()
598 ret = pmic_gpio_write(state, pad, in pmic_gpio_config_set()
603 val = pad->out_value in pmic_gpio_config_set()
605 val |= pad->function in pmic_gpio_config_set()
607 ret = pmic_gpio_write(state, pad, in pmic_gpio_config_set()
613 val |= pad->function << PMIC_GPIO_REG_MODE_FUNCTION_SHIFT; in pmic_gpio_config_set()
614 val |= pad->out_value & PMIC_GPIO_REG_MODE_VALUE_SHIFT; in pmic_gpio_config_set()
616 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_MODE_CTL, val); in pmic_gpio_config_set()
621 val = pad->is_enabled << PMIC_GPIO_REG_MASTER_EN_SHIFT; in pmic_gpio_config_set()
623 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_EN_CTL, val); in pmic_gpio_config_set()
632 struct pmic_gpio_pad *pad; in pmic_gpio_config_dbg_show() local
646 pad = pctldev->desc->pins[pin].drv_data; in pmic_gpio_config_dbg_show()
650 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_EN_CTL); in pmic_gpio_config_dbg_show()
655 if (pad->input_enabled) { in pmic_gpio_config_dbg_show()
656 ret = pmic_gpio_read(state, pad, PMIC_MPP_REG_RT_STS); in pmic_gpio_config_dbg_show()
661 pad->out_value = ret; in pmic_gpio_config_dbg_show()
667 function = pad->function; in pmic_gpio_config_dbg_show()
668 if (!pad->lv_mv_type && in pmic_gpio_config_dbg_show()
669 pad->function >= PMIC_GPIO_FUNC_INDEX_FUNC3) in pmic_gpio_config_dbg_show()
673 if (pad->analog_pass) in pmic_gpio_config_dbg_show()
677 pad->output_enabled ? "out" : "in"); in pmic_gpio_config_dbg_show()
678 seq_printf(s, " %-4s", pad->out_value ? "high" : "low"); in pmic_gpio_config_dbg_show()
680 seq_printf(s, " vin-%d", pad->power_source); in pmic_gpio_config_dbg_show()
681 seq_printf(s, " %-27s", biases[pad->pullup]); in pmic_gpio_config_dbg_show()
682 seq_printf(s, " %-10s", buffer_types[pad->buffer_type]); in pmic_gpio_config_dbg_show()
683 seq_printf(s, " %-7s", strengths[pad->strength]); in pmic_gpio_config_dbg_show()
684 seq_printf(s, " atest-%d", pad->atest); in pmic_gpio_config_dbg_show()
685 seq_printf(s, " dtest-%d", pad->dtest_buffer); in pmic_gpio_config_dbg_show()
720 struct pmic_gpio_pad *pad; in pmic_gpio_get() local
723 pad = state->ctrl->desc->pins[pin].drv_data; in pmic_gpio_get()
725 if (!pad->is_enabled) in pmic_gpio_get()
728 if (pad->input_enabled) { in pmic_gpio_get()
729 ret = pmic_gpio_read(state, pad, PMIC_MPP_REG_RT_STS); in pmic_gpio_get()
733 pad->out_value = ret & PMIC_MPP_REG_RT_STS_VAL_MASK; in pmic_gpio_get()
736 return !!pad->out_value; in pmic_gpio_get()
785 struct pmic_gpio_pad *pad) in pmic_gpio_populate() argument
789 type = pmic_gpio_read(state, pad, PMIC_GPIO_REG_TYPE); in pmic_gpio_populate()
795 type, pad->base); in pmic_gpio_populate()
799 subtype = pmic_gpio_read(state, pad, PMIC_GPIO_REG_SUBTYPE); in pmic_gpio_populate()
805 pad->have_buffer = true; in pmic_gpio_populate()
808 pad->num_sources = 4; in pmic_gpio_populate()
811 pad->have_buffer = true; in pmic_gpio_populate()
814 pad->num_sources = 8; in pmic_gpio_populate()
817 pad->num_sources = 1; in pmic_gpio_populate()
818 pad->have_buffer = true; in pmic_gpio_populate()
819 pad->lv_mv_type = true; in pmic_gpio_populate()
822 pad->num_sources = 2; in pmic_gpio_populate()
823 pad->have_buffer = true; in pmic_gpio_populate()
824 pad->lv_mv_type = true; in pmic_gpio_populate()
831 if (pad->lv_mv_type) { in pmic_gpio_populate()
832 val = pmic_gpio_read(state, pad, in pmic_gpio_populate()
837 pad->out_value = !!(val & PMIC_GPIO_LV_MV_OUTPUT_INVERT); in pmic_gpio_populate()
838 pad->function = val & PMIC_GPIO_LV_MV_OUTPUT_SOURCE_SEL_MASK; in pmic_gpio_populate()
840 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_MODE_CTL); in pmic_gpio_populate()
846 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_MODE_CTL); in pmic_gpio_populate()
850 pad->out_value = val & PMIC_GPIO_REG_MODE_VALUE_SHIFT; in pmic_gpio_populate()
854 pad->function = val >> PMIC_GPIO_REG_MODE_FUNCTION_SHIFT; in pmic_gpio_populate()
855 pad->function &= PMIC_GPIO_REG_MODE_FUNCTION_MASK; in pmic_gpio_populate()
860 pad->input_enabled = true; in pmic_gpio_populate()
861 pad->output_enabled = false; in pmic_gpio_populate()
864 pad->input_enabled = false; in pmic_gpio_populate()
865 pad->output_enabled = true; in pmic_gpio_populate()
868 pad->input_enabled = true; in pmic_gpio_populate()
869 pad->output_enabled = true; in pmic_gpio_populate()
872 if (!pad->lv_mv_type) in pmic_gpio_populate()
874 pad->analog_pass = true; in pmic_gpio_populate()
881 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_VIN_CTL); in pmic_gpio_populate()
885 pad->power_source = val >> PMIC_GPIO_REG_VIN_SHIFT; in pmic_gpio_populate()
886 pad->power_source &= PMIC_GPIO_REG_VIN_MASK; in pmic_gpio_populate()
888 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_PULL_CTL); in pmic_gpio_populate()
892 pad->pullup = val >> PMIC_GPIO_REG_PULL_SHIFT; in pmic_gpio_populate()
893 pad->pullup &= PMIC_GPIO_REG_PULL_MASK; in pmic_gpio_populate()
895 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_IN_CTL); in pmic_gpio_populate()
899 if (pad->lv_mv_type && (val & PMIC_GPIO_LV_MV_DIG_IN_DTEST_EN)) in pmic_gpio_populate()
900 pad->dtest_buffer = in pmic_gpio_populate()
902 else if (!pad->lv_mv_type) in pmic_gpio_populate()
903 pad->dtest_buffer = ffs(val); in pmic_gpio_populate()
905 pad->dtest_buffer = 0; in pmic_gpio_populate()
907 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_OUT_CTL); in pmic_gpio_populate()
911 pad->strength = val >> PMIC_GPIO_REG_OUT_STRENGTH_SHIFT; in pmic_gpio_populate()
912 pad->strength &= PMIC_GPIO_REG_OUT_STRENGTH_MASK; in pmic_gpio_populate()
914 pad->buffer_type = val >> PMIC_GPIO_REG_OUT_TYPE_SHIFT; in pmic_gpio_populate()
915 pad->buffer_type &= PMIC_GPIO_REG_OUT_TYPE_MASK; in pmic_gpio_populate()
917 if (pad->lv_mv_type) { in pmic_gpio_populate()
918 val = pmic_gpio_read(state, pad, in pmic_gpio_populate()
922 pad->atest = (val & PMIC_GPIO_LV_MV_ANA_MUX_SEL_MASK) + 1; in pmic_gpio_populate()
926 pad->is_enabled = true; in pmic_gpio_populate()
998 struct pmic_gpio_pad *pad, *pads; in pmic_gpio_probe() local
1051 pad = &pads[i]; in pmic_gpio_probe()
1052 pindesc->drv_data = pad; in pmic_gpio_probe()
1056 pad->base = reg + i * PMIC_GPIO_ADDRESS_RANGE; in pmic_gpio_probe()
1058 ret = pmic_gpio_populate(state, pad); in pmic_gpio_probe()