diff options
author | Manjunathappa, Prakash <prakash.pm@ti.com> | 2013-05-21 10:08:01 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-06-16 05:56:52 -0400 |
commit | 6f924b0b7cbe2a3d9c08f6134343fd366c35fdfa (patch) | |
tree | 78949fd6aa18535a8c7b4d505a165beaba5961e4 /drivers/pinctrl/pinctrl-single.c | |
parent | 4e7e8017a80e1810100c9b416b86e3baef900285 (diff) |
pinctrl: pinctrl-single: pin names for pinctrl-single.bits
Take care to name pin names as
register-offset.bit-pos-of-pin-in-register in case configuring multiple
pins in register.
Signed-off-by: Manjunathappa, Prakash <prakash.pm@ti.com>
Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-single.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-single.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 9a1ea65014d7..2899c866a3fb 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #define DRIVER_NAME "pinctrl-single" | 30 | #define DRIVER_NAME "pinctrl-single" |
31 | #define PCS_MUX_PINS_NAME "pinctrl-single,pins" | 31 | #define PCS_MUX_PINS_NAME "pinctrl-single,pins" |
32 | #define PCS_MUX_BITS_NAME "pinctrl-single,bits" | 32 | #define PCS_MUX_BITS_NAME "pinctrl-single,bits" |
33 | #define PCS_REG_NAME_LEN ((sizeof(unsigned long) * 2) + 1) | 33 | #define PCS_REG_NAME_LEN ((sizeof(unsigned long) * 2) + 3) |
34 | #define PCS_OFF_DISABLED ~0U | 34 | #define PCS_OFF_DISABLED ~0U |
35 | 35 | ||
36 | /** | 36 | /** |
@@ -744,7 +744,8 @@ static const struct pinconf_ops pcs_pinconf_ops = { | |||
744 | * @pcs: pcs driver instance | 744 | * @pcs: pcs driver instance |
745 | * @offset: register offset from base | 745 | * @offset: register offset from base |
746 | */ | 746 | */ |
747 | static int pcs_add_pin(struct pcs_device *pcs, unsigned offset) | 747 | static int pcs_add_pin(struct pcs_device *pcs, unsigned offset, |
748 | unsigned pin_pos) | ||
748 | { | 749 | { |
749 | struct pinctrl_pin_desc *pin; | 750 | struct pinctrl_pin_desc *pin; |
750 | struct pcs_name *pn; | 751 | struct pcs_name *pn; |
@@ -759,8 +760,8 @@ static int pcs_add_pin(struct pcs_device *pcs, unsigned offset) | |||
759 | 760 | ||
760 | pin = &pcs->pins.pa[i]; | 761 | pin = &pcs->pins.pa[i]; |
761 | pn = &pcs->names[i]; | 762 | pn = &pcs->names[i]; |
762 | sprintf(pn->name, "%lx", | 763 | sprintf(pn->name, "%lx.%d", |
763 | (unsigned long)pcs->res->start + offset); | 764 | (unsigned long)pcs->res->start + offset, pin_pos); |
764 | pin->name = pn->name; | 765 | pin->name = pn->name; |
765 | pin->number = i; | 766 | pin->number = i; |
766 | pcs->pins.cur++; | 767 | pcs->pins.cur++; |
@@ -780,12 +781,14 @@ static int pcs_add_pin(struct pcs_device *pcs, unsigned offset) | |||
780 | static int pcs_allocate_pin_table(struct pcs_device *pcs) | 781 | static int pcs_allocate_pin_table(struct pcs_device *pcs) |
781 | { | 782 | { |
782 | int mux_bytes, nr_pins, i; | 783 | int mux_bytes, nr_pins, i; |
784 | int num_pins_in_register = 0; | ||
783 | 785 | ||
784 | mux_bytes = pcs->width / BITS_PER_BYTE; | 786 | mux_bytes = pcs->width / BITS_PER_BYTE; |
785 | 787 | ||
786 | if (pcs->bits_per_mux) { | 788 | if (pcs->bits_per_mux) { |
787 | pcs->bits_per_pin = fls(pcs->fmask); | 789 | pcs->bits_per_pin = fls(pcs->fmask); |
788 | nr_pins = (pcs->size * BITS_PER_BYTE) / pcs->bits_per_pin; | 790 | nr_pins = (pcs->size * BITS_PER_BYTE) / pcs->bits_per_pin; |
791 | num_pins_in_register = pcs->width / pcs->bits_per_pin; | ||
789 | } else { | 792 | } else { |
790 | nr_pins = pcs->size / mux_bytes; | 793 | nr_pins = pcs->size / mux_bytes; |
791 | } | 794 | } |
@@ -810,14 +813,16 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs) | |||
810 | unsigned offset; | 813 | unsigned offset; |
811 | int res; | 814 | int res; |
812 | int byte_num; | 815 | int byte_num; |
816 | int pin_pos = 0; | ||
813 | 817 | ||
814 | if (pcs->bits_per_mux) { | 818 | if (pcs->bits_per_mux) { |
815 | byte_num = (pcs->bits_per_pin * i) / BITS_PER_BYTE; | 819 | byte_num = (pcs->bits_per_pin * i) / BITS_PER_BYTE; |
816 | offset = (byte_num / mux_bytes) * mux_bytes; | 820 | offset = (byte_num / mux_bytes) * mux_bytes; |
821 | pin_pos = i % num_pins_in_register; | ||
817 | } else { | 822 | } else { |
818 | offset = i * mux_bytes; | 823 | offset = i * mux_bytes; |
819 | } | 824 | } |
820 | res = pcs_add_pin(pcs, offset); | 825 | res = pcs_add_pin(pcs, offset, pin_pos); |
821 | if (res < 0) { | 826 | if (res < 0) { |
822 | dev_err(pcs->dev, "error adding pins: %i\n", res); | 827 | dev_err(pcs->dev, "error adding pins: %i\n", res); |
823 | return res; | 828 | return res; |