Lines Matching full:pad
224 struct pmic_gpio_pad *pad, unsigned int addr) in pmic_gpio_read() argument
229 ret = regmap_read(state->map, pad->base + addr, &val); in pmic_gpio_read()
239 struct pmic_gpio_pad *pad, unsigned int addr, in pmic_gpio_write() argument
244 ret = regmap_write(state->map, pad->base + addr, val); in pmic_gpio_write()
304 struct pmic_gpio_pad *pad; in pmic_gpio_set_mux() local
313 pad = pctldev->desc->pins[pin].drv_data; in pmic_gpio_set_mux()
318 if (!pad->lv_mv_type) { in pmic_gpio_set_mux()
329 pad->function = function; in pmic_gpio_set_mux()
331 if (pad->analog_pass) in pmic_gpio_set_mux()
333 else if (pad->output_enabled && pad->input_enabled) in pmic_gpio_set_mux()
335 else if (pad->output_enabled) in pmic_gpio_set_mux()
340 if (pad->lv_mv_type) { in pmic_gpio_set_mux()
341 ret = pmic_gpio_write(state, pad, in pmic_gpio_set_mux()
346 val = pad->atest - 1; in pmic_gpio_set_mux()
347 ret = pmic_gpio_write(state, pad, in pmic_gpio_set_mux()
352 val = pad->out_value in pmic_gpio_set_mux()
354 val |= pad->function in pmic_gpio_set_mux()
356 ret = pmic_gpio_write(state, pad, in pmic_gpio_set_mux()
362 val |= pad->function << PMIC_GPIO_REG_MODE_FUNCTION_SHIFT; in pmic_gpio_set_mux()
363 val |= pad->out_value & PMIC_GPIO_REG_MODE_VALUE_SHIFT; in pmic_gpio_set_mux()
365 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_MODE_CTL, val); in pmic_gpio_set_mux()
370 val = pad->is_enabled << PMIC_GPIO_REG_MASTER_EN_SHIFT; in pmic_gpio_set_mux()
372 return pmic_gpio_write(state, pad, PMIC_GPIO_REG_EN_CTL, val); in pmic_gpio_set_mux()
386 struct pmic_gpio_pad *pad; in pmic_gpio_config_get() local
389 pad = pctldev->desc->pins[pin].drv_data; in pmic_gpio_config_get()
393 if (pad->buffer_type != PMIC_GPIO_OUT_BUF_CMOS) in pmic_gpio_config_get()
398 if (pad->buffer_type != PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS) in pmic_gpio_config_get()
403 if (pad->buffer_type != PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS) in pmic_gpio_config_get()
408 if (pad->pullup != PMIC_GPIO_PULL_DOWN) in pmic_gpio_config_get()
413 if (pad->pullup != PMIC_GPIO_PULL_DISABLE) in pmic_gpio_config_get()
418 if (pad->pullup != PMIC_GPIO_PULL_UP_30) in pmic_gpio_config_get()
423 if (pad->is_enabled) in pmic_gpio_config_get()
428 arg = pad->power_source; in pmic_gpio_config_get()
431 if (!pad->input_enabled) in pmic_gpio_config_get()
436 arg = pad->output_enabled; in pmic_gpio_config_get()
439 arg = pad->out_value; in pmic_gpio_config_get()
442 arg = pad->pullup; in pmic_gpio_config_get()
445 switch (pad->strength) { in pmic_gpio_config_get()
453 arg = pad->strength; in pmic_gpio_config_get()
458 arg = pad->atest; in pmic_gpio_config_get()
461 arg = pad->analog_pass; in pmic_gpio_config_get()
464 arg = pad->dtest_buffer; in pmic_gpio_config_get()
478 struct pmic_gpio_pad *pad; in pmic_gpio_config_set() local
483 pad = pctldev->desc->pins[pin].drv_data; in pmic_gpio_config_set()
485 pad->is_enabled = true; in pmic_gpio_config_set()
492 pad->buffer_type = PMIC_GPIO_OUT_BUF_CMOS; in pmic_gpio_config_set()
495 if (!pad->have_buffer) in pmic_gpio_config_set()
497 pad->buffer_type = PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS; in pmic_gpio_config_set()
500 if (!pad->have_buffer) in pmic_gpio_config_set()
502 pad->buffer_type = PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS; in pmic_gpio_config_set()
505 pad->pullup = PMIC_GPIO_PULL_DISABLE; in pmic_gpio_config_set()
508 pad->pullup = PMIC_GPIO_PULL_UP_30; in pmic_gpio_config_set()
512 pad->pullup = PMIC_GPIO_PULL_DOWN; in pmic_gpio_config_set()
514 pad->pullup = PMIC_GPIO_PULL_DISABLE; in pmic_gpio_config_set()
517 pad->is_enabled = false; in pmic_gpio_config_set()
520 if (arg >= pad->num_sources) in pmic_gpio_config_set()
522 pad->power_source = arg; in pmic_gpio_config_set()
525 pad->input_enabled = arg ? true : false; in pmic_gpio_config_set()
528 pad->output_enabled = arg ? true : false; in pmic_gpio_config_set()
531 pad->output_enabled = true; in pmic_gpio_config_set()
532 pad->out_value = arg; in pmic_gpio_config_set()
537 pad->pullup = arg; in pmic_gpio_config_set()
544 pad->strength = PMIC_GPIO_OUT_STRENGTH_HIGH; in pmic_gpio_config_set()
547 pad->strength = PMIC_GPIO_OUT_STRENGTH_LOW; in pmic_gpio_config_set()
550 pad->strength = arg; in pmic_gpio_config_set()
555 if (!pad->lv_mv_type || arg > 4) in pmic_gpio_config_set()
557 pad->atest = arg; in pmic_gpio_config_set()
560 if (!pad->lv_mv_type) in pmic_gpio_config_set()
562 pad->analog_pass = true; in pmic_gpio_config_set()
567 pad->dtest_buffer = arg; in pmic_gpio_config_set()
574 val = pad->power_source << PMIC_GPIO_REG_VIN_SHIFT; in pmic_gpio_config_set()
576 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_VIN_CTL, val); in pmic_gpio_config_set()
580 val = pad->pullup << PMIC_GPIO_REG_PULL_SHIFT; in pmic_gpio_config_set()
582 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_PULL_CTL, val); in pmic_gpio_config_set()
586 val = pad->buffer_type << PMIC_GPIO_REG_OUT_TYPE_SHIFT; in pmic_gpio_config_set()
587 val |= pad->strength << PMIC_GPIO_REG_OUT_STRENGTH_SHIFT; in pmic_gpio_config_set()
589 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_OUT_CTL, val); in pmic_gpio_config_set()
593 if (pad->dtest_buffer == 0) { in pmic_gpio_config_set()
596 if (pad->lv_mv_type) { in pmic_gpio_config_set()
597 val = pad->dtest_buffer - 1; in pmic_gpio_config_set()
600 val = BIT(pad->dtest_buffer - 1); in pmic_gpio_config_set()
603 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_DIG_IN_CTL, val); in pmic_gpio_config_set()
607 if (pad->analog_pass) in pmic_gpio_config_set()
609 else if (pad->output_enabled && pad->input_enabled) in pmic_gpio_config_set()
611 else if (pad->output_enabled) in pmic_gpio_config_set()
616 if (pad->lv_mv_type) { in pmic_gpio_config_set()
617 ret = pmic_gpio_write(state, pad, in pmic_gpio_config_set()
622 val = pad->atest - 1; in pmic_gpio_config_set()
623 ret = pmic_gpio_write(state, pad, in pmic_gpio_config_set()
628 val = pad->out_value in pmic_gpio_config_set()
630 val |= pad->function in pmic_gpio_config_set()
632 ret = pmic_gpio_write(state, pad, in pmic_gpio_config_set()
638 val |= pad->function << PMIC_GPIO_REG_MODE_FUNCTION_SHIFT; in pmic_gpio_config_set()
639 val |= pad->out_value & PMIC_GPIO_REG_MODE_VALUE_SHIFT; in pmic_gpio_config_set()
641 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_MODE_CTL, val); in pmic_gpio_config_set()
646 val = pad->is_enabled << PMIC_GPIO_REG_MASTER_EN_SHIFT; in pmic_gpio_config_set()
648 ret = pmic_gpio_write(state, pad, PMIC_GPIO_REG_EN_CTL, val); in pmic_gpio_config_set()
657 struct pmic_gpio_pad *pad; in pmic_gpio_config_dbg_show() local
671 pad = pctldev->desc->pins[pin].drv_data; in pmic_gpio_config_dbg_show()
675 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_EN_CTL); in pmic_gpio_config_dbg_show()
680 if (pad->input_enabled) { in pmic_gpio_config_dbg_show()
681 ret = pmic_gpio_read(state, pad, PMIC_MPP_REG_RT_STS); in pmic_gpio_config_dbg_show()
686 pad->out_value = ret; in pmic_gpio_config_dbg_show()
692 function = pad->function; in pmic_gpio_config_dbg_show()
693 if (!pad->lv_mv_type && in pmic_gpio_config_dbg_show()
694 pad->function >= PMIC_GPIO_FUNC_INDEX_FUNC3) in pmic_gpio_config_dbg_show()
698 if (pad->analog_pass) in pmic_gpio_config_dbg_show()
702 pad->output_enabled ? "out" : "in"); in pmic_gpio_config_dbg_show()
703 seq_printf(s, " %-4s", pad->out_value ? "high" : "low"); in pmic_gpio_config_dbg_show()
705 seq_printf(s, " vin-%d", pad->power_source); in pmic_gpio_config_dbg_show()
706 seq_printf(s, " %-27s", biases[pad->pullup]); in pmic_gpio_config_dbg_show()
707 seq_printf(s, " %-10s", buffer_types[pad->buffer_type]); in pmic_gpio_config_dbg_show()
708 seq_printf(s, " %-7s", strengths[pad->strength]); in pmic_gpio_config_dbg_show()
709 seq_printf(s, " atest-%d", pad->atest); in pmic_gpio_config_dbg_show()
710 seq_printf(s, " dtest-%d", pad->dtest_buffer); in pmic_gpio_config_dbg_show()
745 struct pmic_gpio_pad *pad; in pmic_gpio_get() local
748 pad = state->ctrl->desc->pins[pin].drv_data; in pmic_gpio_get()
750 if (!pad->is_enabled) in pmic_gpio_get()
753 if (pad->input_enabled) { in pmic_gpio_get()
754 ret = pmic_gpio_read(state, pad, PMIC_MPP_REG_RT_STS); in pmic_gpio_get()
758 pad->out_value = ret & PMIC_MPP_REG_RT_STS_VAL_MASK; in pmic_gpio_get()
761 return !!pad->out_value; in pmic_gpio_get()
810 struct pmic_gpio_pad *pad) in pmic_gpio_populate() argument
814 type = pmic_gpio_read(state, pad, PMIC_GPIO_REG_TYPE); in pmic_gpio_populate()
820 type, pad->base); in pmic_gpio_populate()
824 subtype = pmic_gpio_read(state, pad, PMIC_GPIO_REG_SUBTYPE); in pmic_gpio_populate()
830 pad->have_buffer = true; in pmic_gpio_populate()
833 pad->num_sources = 4; in pmic_gpio_populate()
836 pad->have_buffer = true; in pmic_gpio_populate()
839 pad->num_sources = 8; in pmic_gpio_populate()
842 pad->num_sources = 1; in pmic_gpio_populate()
843 pad->have_buffer = true; in pmic_gpio_populate()
844 pad->lv_mv_type = true; in pmic_gpio_populate()
847 pad->num_sources = 2; in pmic_gpio_populate()
848 pad->have_buffer = true; in pmic_gpio_populate()
849 pad->lv_mv_type = true; in pmic_gpio_populate()
852 pad->num_sources = 2; in pmic_gpio_populate()
853 pad->have_buffer = true; in pmic_gpio_populate()
854 pad->lv_mv_type = true; in pmic_gpio_populate()
857 pad->num_sources = 3; in pmic_gpio_populate()
858 pad->have_buffer = true; in pmic_gpio_populate()
859 pad->lv_mv_type = true; in pmic_gpio_populate()
866 if (pad->lv_mv_type) { in pmic_gpio_populate()
867 val = pmic_gpio_read(state, pad, in pmic_gpio_populate()
872 pad->out_value = !!(val & PMIC_GPIO_LV_MV_OUTPUT_INVERT); in pmic_gpio_populate()
873 pad->function = val & PMIC_GPIO_LV_MV_OUTPUT_SOURCE_SEL_MASK; in pmic_gpio_populate()
875 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_MODE_CTL); in pmic_gpio_populate()
881 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_MODE_CTL); in pmic_gpio_populate()
885 pad->out_value = val & PMIC_GPIO_REG_MODE_VALUE_SHIFT; in pmic_gpio_populate()
889 pad->function = val >> PMIC_GPIO_REG_MODE_FUNCTION_SHIFT; in pmic_gpio_populate()
890 pad->function &= PMIC_GPIO_REG_MODE_FUNCTION_MASK; in pmic_gpio_populate()
895 pad->input_enabled = true; in pmic_gpio_populate()
896 pad->output_enabled = false; in pmic_gpio_populate()
899 pad->input_enabled = false; in pmic_gpio_populate()
900 pad->output_enabled = true; in pmic_gpio_populate()
903 pad->input_enabled = true; in pmic_gpio_populate()
904 pad->output_enabled = true; in pmic_gpio_populate()
907 if (!pad->lv_mv_type) in pmic_gpio_populate()
909 pad->analog_pass = true; in pmic_gpio_populate()
916 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_VIN_CTL); in pmic_gpio_populate()
920 pad->power_source = val >> PMIC_GPIO_REG_VIN_SHIFT; in pmic_gpio_populate()
921 pad->power_source &= PMIC_GPIO_REG_VIN_MASK; in pmic_gpio_populate()
923 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_PULL_CTL); in pmic_gpio_populate()
927 pad->pullup = val >> PMIC_GPIO_REG_PULL_SHIFT; in pmic_gpio_populate()
928 pad->pullup &= PMIC_GPIO_REG_PULL_MASK; in pmic_gpio_populate()
930 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_IN_CTL); in pmic_gpio_populate()
934 if (pad->lv_mv_type && (val & PMIC_GPIO_LV_MV_DIG_IN_DTEST_EN)) in pmic_gpio_populate()
935 pad->dtest_buffer = in pmic_gpio_populate()
937 else if (!pad->lv_mv_type) in pmic_gpio_populate()
938 pad->dtest_buffer = ffs(val); in pmic_gpio_populate()
940 pad->dtest_buffer = 0; in pmic_gpio_populate()
942 val = pmic_gpio_read(state, pad, PMIC_GPIO_REG_DIG_OUT_CTL); in pmic_gpio_populate()
946 pad->strength = val >> PMIC_GPIO_REG_OUT_STRENGTH_SHIFT; in pmic_gpio_populate()
947 pad->strength &= PMIC_GPIO_REG_OUT_STRENGTH_MASK; in pmic_gpio_populate()
949 pad->buffer_type = val >> PMIC_GPIO_REG_OUT_TYPE_SHIFT; in pmic_gpio_populate()
950 pad->buffer_type &= PMIC_GPIO_REG_OUT_TYPE_MASK; in pmic_gpio_populate()
952 if (pad->lv_mv_type) { in pmic_gpio_populate()
953 val = pmic_gpio_read(state, pad, in pmic_gpio_populate()
957 pad->atest = (val & PMIC_GPIO_LV_MV_ANA_MUX_SEL_MASK) + 1; in pmic_gpio_populate()
961 pad->is_enabled = true; in pmic_gpio_populate()
1057 struct pmic_gpio_pad *pad, *pads; in pmic_gpio_probe() local
1110 pad = &pads[i]; in pmic_gpio_probe()
1111 pindesc->drv_data = pad; in pmic_gpio_probe()
1115 pad->base = reg + i * PMIC_GPIO_ADDRESS_RANGE; in pmic_gpio_probe()
1117 ret = pmic_gpio_populate(state, pad); in pmic_gpio_probe()