Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2016 |
Mario Six | d38826a | 2018-03-06 08:04:58 +0100 | [diff] [blame] | 4 | * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 5 | * |
| 6 | * based on arch/powerpc/include/asm/mpc85xx_gpio.h, which is |
| 7 | * |
| 8 | * Copyright 2010 eXMeritus, A Boeing Company |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 9 | * Copyright 2020 NXP |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #include <dm.h> |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 14 | #include <mapmem.h> |
Mario Six | f9c7fde | 2018-01-15 11:07:49 +0100 | [diff] [blame] | 15 | #include <asm/gpio.h> |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 16 | #include <asm/io.h> |
| 17 | #include <dm/of_access.h> |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 18 | |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 19 | struct ccsr_gpio { |
| 20 | u32 gpdir; |
| 21 | u32 gpodr; |
| 22 | u32 gpdat; |
| 23 | u32 gpier; |
| 24 | u32 gpimr; |
| 25 | u32 gpicr; |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 26 | u32 gpibe; |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 27 | }; |
| 28 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 29 | struct mpc8xxx_gpio_data { |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 30 | /* The bank's register base in memory */ |
| 31 | struct ccsr_gpio __iomem *base; |
| 32 | /* The address of the registers; used to identify the bank */ |
| 33 | ulong addr; |
| 34 | /* The GPIO count of the bank */ |
| 35 | uint gpio_count; |
| 36 | /* The GPDAT register cannot be used to determine the value of output |
| 37 | * pins on MPC8572/MPC8536, so we shadow it and use the shadowed value |
Mario Six | aadc5e6 | 2018-01-15 11:07:46 +0100 | [diff] [blame] | 38 | * for output pins |
| 39 | */ |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 40 | u32 dat_shadow; |
Mario Six | f9c7fde | 2018-01-15 11:07:49 +0100 | [diff] [blame] | 41 | ulong type; |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 42 | bool little_endian; |
Mario Six | f9c7fde | 2018-01-15 11:07:49 +0100 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | enum { |
| 46 | MPC8XXX_GPIO_TYPE, |
| 47 | MPC5121_GPIO_TYPE, |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 48 | }; |
| 49 | |
Mario Six | aadc5e6 | 2018-01-15 11:07:46 +0100 | [diff] [blame] | 50 | inline u32 gpio_mask(uint gpio) |
| 51 | { |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 52 | return (1U << (31 - (gpio))); |
| 53 | } |
| 54 | |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 55 | static inline u32 mpc8xxx_gpio_get_val(struct udevice *dev, u32 mask) |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 56 | { |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 57 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
| 58 | |
| 59 | if (data->little_endian) |
| 60 | return in_le32(&data->base->gpdat) & mask; |
| 61 | else |
| 62 | return in_be32(&data->base->gpdat) & mask; |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 63 | } |
| 64 | |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 65 | static inline u32 mpc8xxx_gpio_get_dir(struct udevice *dev, u32 mask) |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 66 | { |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 67 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
| 68 | |
| 69 | if (data->little_endian) |
| 70 | return in_le32(&data->base->gpdir) & mask; |
| 71 | else |
| 72 | return in_be32(&data->base->gpdir) & mask; |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 73 | } |
| 74 | |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 75 | static inline int mpc8xxx_gpio_open_drain_val(struct udevice *dev, u32 mask) |
mario.six@gdsys.cc | 5178178 | 2016-05-25 15:15:22 +0200 | [diff] [blame] | 76 | { |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 77 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
| 78 | |
| 79 | if (data->little_endian) |
| 80 | return in_le32(&data->base->gpodr) & mask; |
| 81 | else |
| 82 | return in_be32(&data->base->gpodr) & mask; |
mario.six@gdsys.cc | 5178178 | 2016-05-25 15:15:22 +0200 | [diff] [blame] | 83 | } |
| 84 | |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 85 | static inline void mpc8xxx_gpio_open_drain_on(struct udevice *dev, u32 |
mario.six@gdsys.cc | 5178178 | 2016-05-25 15:15:22 +0200 | [diff] [blame] | 86 | gpios) |
| 87 | { |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 88 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
mario.six@gdsys.cc | 5178178 | 2016-05-25 15:15:22 +0200 | [diff] [blame] | 89 | /* GPODR register 1 -> open drain on */ |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 90 | if (data->little_endian) |
| 91 | setbits_le32(&data->base->gpodr, gpios); |
| 92 | else |
| 93 | setbits_be32(&data->base->gpodr, gpios); |
mario.six@gdsys.cc | 5178178 | 2016-05-25 15:15:22 +0200 | [diff] [blame] | 94 | } |
| 95 | |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 96 | static inline void mpc8xxx_gpio_open_drain_off(struct udevice *dev, |
mario.six@gdsys.cc | 5178178 | 2016-05-25 15:15:22 +0200 | [diff] [blame] | 97 | u32 gpios) |
| 98 | { |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 99 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
mario.six@gdsys.cc | 5178178 | 2016-05-25 15:15:22 +0200 | [diff] [blame] | 100 | /* GPODR register 0 -> open drain off (actively driven) */ |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 101 | if (data->little_endian) |
| 102 | clrbits_le32(&data->base->gpodr, gpios); |
| 103 | else |
| 104 | clrbits_be32(&data->base->gpodr, gpios); |
mario.six@gdsys.cc | 5178178 | 2016-05-25 15:15:22 +0200 | [diff] [blame] | 105 | } |
| 106 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 107 | static int mpc8xxx_gpio_direction_input(struct udevice *dev, uint gpio) |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 108 | { |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 109 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
Rasmus Villemoes | 1d7ad9f | 2020-01-28 12:04:33 +0000 | [diff] [blame] | 110 | u32 mask = gpio_mask(gpio); |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 111 | |
Rasmus Villemoes | 1d7ad9f | 2020-01-28 12:04:33 +0000 | [diff] [blame] | 112 | /* GPDIR register 0 -> input */ |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 113 | if (data->little_endian) |
| 114 | clrbits_le32(&data->base->gpdir, mask); |
| 115 | else |
| 116 | clrbits_be32(&data->base->gpdir, mask); |
Rasmus Villemoes | 1d7ad9f | 2020-01-28 12:04:33 +0000 | [diff] [blame] | 117 | |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 118 | return 0; |
| 119 | } |
| 120 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 121 | static int mpc8xxx_gpio_set_value(struct udevice *dev, uint gpio, int value) |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 122 | { |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 123 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
Rasmus Villemoes | dd4cf53 | 2020-01-28 12:04:34 +0000 | [diff] [blame] | 124 | struct ccsr_gpio *base = data->base; |
| 125 | u32 mask = gpio_mask(gpio); |
| 126 | u32 gpdir; |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 127 | |
| 128 | if (value) { |
Rasmus Villemoes | dd4cf53 | 2020-01-28 12:04:34 +0000 | [diff] [blame] | 129 | data->dat_shadow |= mask; |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 130 | } else { |
Rasmus Villemoes | dd4cf53 | 2020-01-28 12:04:34 +0000 | [diff] [blame] | 131 | data->dat_shadow &= ~mask; |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 132 | } |
Rasmus Villemoes | dd4cf53 | 2020-01-28 12:04:34 +0000 | [diff] [blame] | 133 | |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 134 | if (data->little_endian) |
| 135 | gpdir = in_le32(&base->gpdir); |
| 136 | else |
| 137 | gpdir = in_be32(&base->gpdir); |
| 138 | |
Rasmus Villemoes | dd4cf53 | 2020-01-28 12:04:34 +0000 | [diff] [blame] | 139 | gpdir |= gpio_mask(gpio); |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 140 | |
| 141 | if (data->little_endian) { |
| 142 | out_le32(&base->gpdat, gpdir & data->dat_shadow); |
| 143 | out_le32(&base->gpdir, gpdir); |
| 144 | } else { |
| 145 | out_be32(&base->gpdat, gpdir & data->dat_shadow); |
| 146 | out_be32(&base->gpdir, gpdir); |
| 147 | } |
Rasmus Villemoes | dd4cf53 | 2020-01-28 12:04:34 +0000 | [diff] [blame] | 148 | |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 149 | return 0; |
| 150 | } |
| 151 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 152 | static int mpc8xxx_gpio_direction_output(struct udevice *dev, uint gpio, |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 153 | int value) |
| 154 | { |
Mario Six | f9c7fde | 2018-01-15 11:07:49 +0100 | [diff] [blame] | 155 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
| 156 | |
| 157 | /* GPIO 28..31 are input only on MPC5121 */ |
| 158 | if (data->type == MPC5121_GPIO_TYPE && gpio >= 28) |
| 159 | return -EINVAL; |
| 160 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 161 | return mpc8xxx_gpio_set_value(dev, gpio, value); |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 162 | } |
| 163 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 164 | static int mpc8xxx_gpio_get_value(struct udevice *dev, uint gpio) |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 165 | { |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 166 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 167 | |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 168 | if (!!mpc8xxx_gpio_get_dir(dev, gpio_mask(gpio))) { |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 169 | /* Output -> use shadowed value */ |
| 170 | return !!(data->dat_shadow & gpio_mask(gpio)); |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 171 | } |
Mario Six | aadc5e6 | 2018-01-15 11:07:46 +0100 | [diff] [blame] | 172 | |
| 173 | /* Input -> read value from GPDAT register */ |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 174 | return !!mpc8xxx_gpio_get_val(dev, gpio_mask(gpio)); |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 175 | } |
| 176 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 177 | static int mpc8xxx_gpio_get_function(struct udevice *dev, uint gpio) |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 178 | { |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 179 | int dir; |
| 180 | |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 181 | dir = !!mpc8xxx_gpio_get_dir(dev, gpio_mask(gpio)); |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 182 | return dir ? GPIOF_OUTPUT : GPIOF_INPUT; |
| 183 | } |
| 184 | |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 185 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
Simon Glass | d1998a9 | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 186 | static int mpc8xxx_gpio_of_to_plat(struct udevice *dev) |
Mario Six | aadc5e6 | 2018-01-15 11:07:46 +0100 | [diff] [blame] | 187 | { |
Simon Glass | c69cda2 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 188 | struct mpc8xxx_gpio_plat *plat = dev_get_plat(dev); |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 189 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 190 | fdt_addr_t addr; |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 191 | u32 i; |
| 192 | u32 reg[4]; |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 193 | |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 194 | if (ofnode_read_bool(dev->node, "little-endian")) |
| 195 | data->little_endian = true; |
| 196 | |
| 197 | if (data->little_endian) |
| 198 | dev_read_u32_array(dev, "reg", reg, 4); |
| 199 | else |
| 200 | dev_read_u32_array(dev, "reg", reg, 2); |
| 201 | |
| 202 | if (data->little_endian) { |
| 203 | for (i = 0; i < 2; i++) |
| 204 | reg[i] = be32_to_cpu(reg[i]); |
| 205 | } |
| 206 | |
Mario Six | f5ac4f2 | 2018-01-15 11:07:50 +0100 | [diff] [blame] | 207 | addr = dev_translate_address(dev, reg); |
| 208 | |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 209 | plat->addr = addr; |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 210 | |
| 211 | if (data->little_endian) |
| 212 | plat->size = reg[3]; |
| 213 | else |
| 214 | plat->size = reg[1]; |
| 215 | |
Mario Six | f5ac4f2 | 2018-01-15 11:07:50 +0100 | [diff] [blame] | 216 | plat->ngpios = dev_read_u32_default(dev, "ngpios", 32); |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 217 | |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 218 | return 0; |
| 219 | } |
| 220 | #endif |
| 221 | |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame^] | 222 | static int mpc8xxx_gpio_plat_to_priv(struct udevice *dev) |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 223 | { |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 224 | struct mpc8xxx_gpio_data *priv = dev_get_priv(dev); |
Simon Glass | c69cda2 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 225 | struct mpc8xxx_gpio_plat *plat = dev_get_plat(dev); |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 226 | unsigned long size = plat->size; |
Mario Six | f9c7fde | 2018-01-15 11:07:49 +0100 | [diff] [blame] | 227 | ulong driver_data = dev_get_driver_data(dev); |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 228 | |
| 229 | if (size == 0) |
| 230 | size = 0x100; |
| 231 | |
| 232 | priv->addr = plat->addr; |
Mario Six | f5ac4f2 | 2018-01-15 11:07:50 +0100 | [diff] [blame] | 233 | priv->base = map_sysmem(plat->addr, size); |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 234 | |
| 235 | if (!priv->base) |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 236 | return -ENOMEM; |
| 237 | |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 238 | priv->gpio_count = plat->ngpios; |
| 239 | priv->dat_shadow = 0; |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 240 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 241 | priv->type = driver_data; |
| 242 | |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 243 | return 0; |
| 244 | } |
| 245 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 246 | static int mpc8xxx_gpio_probe(struct udevice *dev) |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 247 | { |
| 248 | struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 249 | struct mpc8xxx_gpio_data *data = dev_get_priv(dev); |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 250 | char name[32], *str; |
| 251 | |
Simon Glass | 8a8d24b | 2020-12-03 16:55:23 -0700 | [diff] [blame^] | 252 | mpc8xxx_gpio_plat_to_priv(dev); |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 253 | |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 254 | snprintf(name, sizeof(name), "MPC@%lx_", data->addr); |
| 255 | str = strdup(name); |
| 256 | |
| 257 | if (!str) |
| 258 | return -ENOMEM; |
| 259 | |
hui.song | d5d6b54 | 2020-09-24 21:40:50 +0800 | [diff] [blame] | 260 | if (ofnode_device_is_compatible(dev->node, "fsl,qoriq-gpio")) { |
| 261 | unsigned long gpibe = data->addr + sizeof(struct ccsr_gpio) |
| 262 | - sizeof(u32); |
| 263 | |
| 264 | out_be32((unsigned int *)gpibe, 0xffffffff); |
| 265 | } |
| 266 | |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 267 | uc_priv->bank_name = str; |
| 268 | uc_priv->gpio_count = data->gpio_count; |
| 269 | |
| 270 | return 0; |
| 271 | } |
| 272 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 273 | static const struct dm_gpio_ops gpio_mpc8xxx_ops = { |
| 274 | .direction_input = mpc8xxx_gpio_direction_input, |
| 275 | .direction_output = mpc8xxx_gpio_direction_output, |
| 276 | .get_value = mpc8xxx_gpio_get_value, |
| 277 | .set_value = mpc8xxx_gpio_set_value, |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 278 | .get_function = mpc8xxx_gpio_get_function, |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 279 | }; |
| 280 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 281 | static const struct udevice_id mpc8xxx_gpio_ids[] = { |
Mario Six | f9c7fde | 2018-01-15 11:07:49 +0100 | [diff] [blame] | 282 | { .compatible = "fsl,pq3-gpio", .data = MPC8XXX_GPIO_TYPE }, |
| 283 | { .compatible = "fsl,mpc8308-gpio", .data = MPC8XXX_GPIO_TYPE }, |
| 284 | { .compatible = "fsl,mpc8349-gpio", .data = MPC8XXX_GPIO_TYPE }, |
| 285 | { .compatible = "fsl,mpc8572-gpio", .data = MPC8XXX_GPIO_TYPE}, |
| 286 | { .compatible = "fsl,mpc8610-gpio", .data = MPC8XXX_GPIO_TYPE}, |
| 287 | { .compatible = "fsl,mpc5121-gpio", .data = MPC5121_GPIO_TYPE, }, |
| 288 | { .compatible = "fsl,qoriq-gpio", .data = MPC8XXX_GPIO_TYPE }, |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 289 | { /* sentinel */ } |
| 290 | }; |
| 291 | |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 292 | U_BOOT_DRIVER(gpio_mpc8xxx) = { |
| 293 | .name = "gpio_mpc8xxx", |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 294 | .id = UCLASS_GPIO, |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 295 | .ops = &gpio_mpc8xxx_ops, |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 296 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
Simon Glass | d1998a9 | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 297 | .of_to_plat = mpc8xxx_gpio_of_to_plat, |
Simon Glass | caa4daa | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 298 | .plat_auto = sizeof(struct mpc8xxx_gpio_plat), |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 299 | .of_match = mpc8xxx_gpio_ids, |
Hamish Martin | 4b689f0 | 2016-06-14 10:17:05 +1200 | [diff] [blame] | 300 | #endif |
Mario Six | 3c21683 | 2018-01-15 11:07:48 +0100 | [diff] [blame] | 301 | .probe = mpc8xxx_gpio_probe, |
Simon Glass | 41575d8 | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 302 | .priv_auto = sizeof(struct mpc8xxx_gpio_data), |
mario.six@gdsys.cc | 07d31f8 | 2016-05-25 15:15:20 +0200 | [diff] [blame] | 303 | }; |