pinctrl-meson.c (9959d9a747fddfd9e1a37f2e3fc60cbc956aad3a) | pinctrl-meson.c (6ea3e3bbef3705225bb675a8c57af58420c23f81) |
---|---|
1/* 2 * Pin controller and GPIO driver for Amlogic Meson SoCs 3 * 4 * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * version 2 as published by the Free Software Foundation. --- 206 unchanged lines hidden (view full) --- 215 meson_calc_reg_and_bit(bank, pin, REG_PULLEN, ®, &bit); 216 ret = regmap_update_bits(pc->reg_pullen, reg, BIT(bit), BIT(bit)); 217 if (ret) 218 return ret; 219 220 return 0; 221} 222 | 1/* 2 * Pin controller and GPIO driver for Amlogic Meson SoCs 3 * 4 * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * version 2 as published by the Free Software Foundation. --- 206 unchanged lines hidden (view full) --- 215 meson_calc_reg_and_bit(bank, pin, REG_PULLEN, ®, &bit); 216 ret = regmap_update_bits(pc->reg_pullen, reg, BIT(bit), BIT(bit)); 217 if (ret) 218 return ret; 219 220 return 0; 221} 222 |
223static int meson_pinconf_set_drive_strength(struct meson_pinctrl *pc, 224 unsigned int pin, 225 u16 drive_strength_ua) 226{ 227 struct meson_bank *bank; 228 unsigned int reg, bit, ds_val; 229 int ret; 230 231 if (!pc->reg_ds) { 232 dev_err(pc->dev, "drive-strength not supported\n"); 233 return -ENOTSUPP; 234 } 235 236 ret = meson_get_bank(pc, pin, &bank); 237 if (ret) 238 return ret; 239 240 meson_calc_reg_and_bit(bank, pin, REG_DS, ®, &bit); 241 bit = bit << 1; 242 243 if (drive_strength_ua <= 500) { 244 ds_val = MESON_PINCONF_DRV_500UA; 245 } else if (drive_strength_ua <= 2500) { 246 ds_val = MESON_PINCONF_DRV_2500UA; 247 } else if (drive_strength_ua <= 3000) { 248 ds_val = MESON_PINCONF_DRV_3000UA; 249 } else if (drive_strength_ua <= 4000) { 250 ds_val = MESON_PINCONF_DRV_4000UA; 251 } else { 252 dev_warn_once(pc->dev, 253 "pin %u: invalid drive-strength : %d , default to 4mA\n", 254 pin, drive_strength_ua); 255 ds_val = MESON_PINCONF_DRV_4000UA; 256 } 257 258 ret = regmap_update_bits(pc->reg_ds, reg, 0x3 << bit, ds_val << bit); 259 if (ret) 260 return ret; 261 262 return 0; 263} 264 |
|
223static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, 224 unsigned long *configs, unsigned num_configs) 225{ 226 struct meson_pinctrl *pc = pinctrl_dev_get_drvdata(pcdev); 227 enum pin_config_param param; | 265static int meson_pinconf_set(struct pinctrl_dev *pcdev, unsigned int pin, 266 unsigned long *configs, unsigned num_configs) 267{ 268 struct meson_pinctrl *pc = pinctrl_dev_get_drvdata(pcdev); 269 enum pin_config_param param; |
270 unsigned int drive_strength_ua; |
|
228 int i, ret; 229 230 for (i = 0; i < num_configs; i++) { 231 param = pinconf_to_config_param(configs[i]); 232 233 switch (param) { 234 case PIN_CONFIG_BIAS_DISABLE: 235 ret = meson_pinconf_disable_bias(pc, pin); --- 5 unchanged lines hidden (view full) --- 241 if (ret) 242 return ret; 243 break; 244 case PIN_CONFIG_BIAS_PULL_DOWN: 245 ret = meson_pinconf_enable_bias(pc, pin, false); 246 if (ret) 247 return ret; 248 break; | 271 int i, ret; 272 273 for (i = 0; i < num_configs; i++) { 274 param = pinconf_to_config_param(configs[i]); 275 276 switch (param) { 277 case PIN_CONFIG_BIAS_DISABLE: 278 ret = meson_pinconf_disable_bias(pc, pin); --- 5 unchanged lines hidden (view full) --- 284 if (ret) 285 return ret; 286 break; 287 case PIN_CONFIG_BIAS_PULL_DOWN: 288 ret = meson_pinconf_enable_bias(pc, pin, false); 289 if (ret) 290 return ret; 291 break; |
292 case PIN_CONFIG_DRIVE_STRENGTH_UA: 293 drive_strength_ua = 294 pinconf_to_config_argument(configs[i]); 295 ret = meson_pinconf_set_drive_strength 296 (pc, pin, drive_strength_ua); 297 if (ret) 298 return ret; 299 break; |
|
249 default: 250 return -ENOTSUPP; 251 } 252 } 253 254 return 0; 255} 256 --- 26 unchanged lines hidden (view full) --- 283 conf = PIN_CONFIG_BIAS_PULL_UP; 284 else 285 conf = PIN_CONFIG_BIAS_PULL_DOWN; 286 } 287 288 return conf; 289} 290 | 300 default: 301 return -ENOTSUPP; 302 } 303 } 304 305 return 0; 306} 307 --- 26 unchanged lines hidden (view full) --- 334 conf = PIN_CONFIG_BIAS_PULL_UP; 335 else 336 conf = PIN_CONFIG_BIAS_PULL_DOWN; 337 } 338 339 return conf; 340} 341 |
342static int meson_pinconf_get_drive_strength(struct meson_pinctrl *pc, 343 unsigned int pin, 344 u16 *drive_strength_ua) 345{ 346 struct meson_bank *bank; 347 unsigned int reg, bit; 348 unsigned int val; 349 int ret; 350 351 if (!pc->reg_ds) 352 return -ENOTSUPP; 353 354 ret = meson_get_bank(pc, pin, &bank); 355 if (ret) 356 return ret; 357 358 meson_calc_reg_and_bit(bank, pin, REG_DS, ®, &bit); 359 360 ret = regmap_read(pc->reg_ds, reg, &val); 361 if (ret) 362 return ret; 363 364 switch ((val >> bit) & 0x3) { 365 case MESON_PINCONF_DRV_500UA: 366 *drive_strength_ua = 500; 367 break; 368 case MESON_PINCONF_DRV_2500UA: 369 *drive_strength_ua = 2500; 370 break; 371 case MESON_PINCONF_DRV_3000UA: 372 *drive_strength_ua = 3000; 373 break; 374 case MESON_PINCONF_DRV_4000UA: 375 *drive_strength_ua = 4000; 376 break; 377 default: 378 return -EINVAL; 379 } 380 381 return 0; 382} 383 |
|
291static int meson_pinconf_get(struct pinctrl_dev *pcdev, unsigned int pin, 292 unsigned long *config) 293{ 294 struct meson_pinctrl *pc = pinctrl_dev_get_drvdata(pcdev); 295 enum pin_config_param param = pinconf_to_config_param(*config); 296 u16 arg; | 384static int meson_pinconf_get(struct pinctrl_dev *pcdev, unsigned int pin, 385 unsigned long *config) 386{ 387 struct meson_pinctrl *pc = pinctrl_dev_get_drvdata(pcdev); 388 enum pin_config_param param = pinconf_to_config_param(*config); 389 u16 arg; |
390 int ret; |
|
297 298 switch (param) { 299 case PIN_CONFIG_BIAS_DISABLE: 300 case PIN_CONFIG_BIAS_PULL_DOWN: 301 case PIN_CONFIG_BIAS_PULL_UP: 302 if (meson_pinconf_get_pull(pc, pin) == param) 303 arg = 1; 304 else 305 return -EINVAL; 306 break; | 391 392 switch (param) { 393 case PIN_CONFIG_BIAS_DISABLE: 394 case PIN_CONFIG_BIAS_PULL_DOWN: 395 case PIN_CONFIG_BIAS_PULL_UP: 396 if (meson_pinconf_get_pull(pc, pin) == param) 397 arg = 1; 398 else 399 return -EINVAL; 400 break; |
401 case PIN_CONFIG_DRIVE_STRENGTH_UA: 402 ret = meson_pinconf_get_drive_strength(pc, pin, &arg); 403 if (ret) 404 return ret; 405 break; |
|
307 default: 308 return -ENOTSUPP; 309 } 310 311 *config = pinconf_to_config_packed(param, arg); 312 dev_dbg(pc->dev, "pinconf for pin %u is %lu\n", pin, *config); 313 314 return 0; --- 250 unchanged lines hidden --- | 406 default: 407 return -ENOTSUPP; 408 } 409 410 *config = pinconf_to_config_packed(param, arg); 411 dev_dbg(pc->dev, "pinconf for pin %u is %lu\n", pin, *config); 412 413 return 0; --- 250 unchanged lines hidden --- |