Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge remote-tracking branches 'regmap/topic/64bit' and 'regmap/topic/irq-type' into regmap-next

+239
+21
drivers/base/regmap/regcache.c
··· 543 543 switch (map->cache_word_size) { 544 544 case 1: { 545 545 u8 *cache = base; 546 + 546 547 cache[idx] = val; 547 548 break; 548 549 } 549 550 case 2: { 550 551 u16 *cache = base; 552 + 551 553 cache[idx] = val; 552 554 break; 553 555 } 554 556 case 4: { 555 557 u32 *cache = base; 558 + 556 559 cache[idx] = val; 557 560 break; 558 561 } 562 + #ifdef CONFIG_64BIT 563 + case 8: { 564 + u64 *cache = base; 565 + 566 + cache[idx] = val; 567 + break; 568 + } 569 + #endif 559 570 default: 560 571 BUG(); 561 572 } ··· 587 576 switch (map->cache_word_size) { 588 577 case 1: { 589 578 const u8 *cache = base; 579 + 590 580 return cache[idx]; 591 581 } 592 582 case 2: { 593 583 const u16 *cache = base; 584 + 594 585 return cache[idx]; 595 586 } 596 587 case 4: { 597 588 const u32 *cache = base; 589 + 598 590 return cache[idx]; 599 591 } 592 + #ifdef CONFIG_64BIT 593 + case 8: { 594 + const u64 *cache = base; 595 + 596 + return cache[idx]; 597 + } 598 + #endif 600 599 default: 601 600 BUG(); 602 601 }
+100
drivers/base/regmap/regmap-irq.c
··· 39 39 unsigned int *mask_buf; 40 40 unsigned int *mask_buf_def; 41 41 unsigned int *wake_buf; 42 + unsigned int *type_buf; 43 + unsigned int *type_buf_def; 42 44 43 45 unsigned int irq_reg_stride; 46 + unsigned int type_reg_stride; 44 47 }; 45 48 46 49 static inline const ··· 147 144 } 148 145 } 149 146 147 + for (i = 0; i < d->chip->num_type_reg; i++) { 148 + if (!d->type_buf_def[i]) 149 + continue; 150 + reg = d->chip->type_base + 151 + (i * map->reg_stride * d->type_reg_stride); 152 + if (d->chip->type_invert) 153 + ret = regmap_update_bits(d->map, reg, 154 + d->type_buf_def[i], ~d->type_buf[i]); 155 + else 156 + ret = regmap_update_bits(d->map, reg, 157 + d->type_buf_def[i], d->type_buf[i]); 158 + if (ret != 0) 159 + dev_err(d->map->dev, "Failed to sync type in %x\n", 160 + reg); 161 + } 162 + 150 163 if (d->chip->runtime_pm) 151 164 pm_runtime_put(map->dev); 152 165 ··· 197 178 d->mask_buf[irq_data->reg_offset / map->reg_stride] |= irq_data->mask; 198 179 } 199 180 181 + static int regmap_irq_set_type(struct irq_data *data, unsigned int type) 182 + { 183 + struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data); 184 + struct regmap *map = d->map; 185 + const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->hwirq); 186 + int reg = irq_data->type_reg_offset / map->reg_stride; 187 + 188 + if (!(irq_data->type_rising_mask | irq_data->type_falling_mask)) 189 + return 0; 190 + 191 + d->type_buf[reg] &= ~(irq_data->type_falling_mask | 192 + irq_data->type_rising_mask); 193 + switch (type) { 194 + case IRQ_TYPE_EDGE_FALLING: 195 + d->type_buf[reg] |= irq_data->type_falling_mask; 196 + break; 197 + 198 + case IRQ_TYPE_EDGE_RISING: 199 + d->type_buf[reg] |= irq_data->type_rising_mask; 200 + break; 201 + 202 + case IRQ_TYPE_EDGE_BOTH: 203 + d->type_buf[reg] |= (irq_data->type_falling_mask | 204 + irq_data->type_rising_mask); 205 + break; 206 + 207 + default: 208 + return -EINVAL; 209 + } 210 + return 0; 211 + } 212 + 200 213 static int regmap_irq_set_wake(struct irq_data *data, unsigned int on) 201 214 { 202 215 struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data); ··· 255 204 .irq_bus_sync_unlock = regmap_irq_sync_unlock, 256 205 .irq_disable = regmap_irq_disable, 257 206 .irq_enable = regmap_irq_enable, 207 + .irq_set_type = regmap_irq_set_type, 258 208 .irq_set_wake = regmap_irq_set_wake, 259 209 }; 260 210 ··· 460 408 goto err_alloc; 461 409 } 462 410 411 + if (chip->num_type_reg) { 412 + d->type_buf_def = kcalloc(chip->num_type_reg, 413 + sizeof(unsigned int), GFP_KERNEL); 414 + if (!d->type_buf_def) 415 + goto err_alloc; 416 + 417 + d->type_buf = kcalloc(chip->num_type_reg, sizeof(unsigned int), 418 + GFP_KERNEL); 419 + if (!d->type_buf) 420 + goto err_alloc; 421 + } 422 + 463 423 d->irq_chip = regmap_irq_chip; 464 424 d->irq_chip.name = chip->name; 465 425 d->irq = irq; ··· 483 419 d->irq_reg_stride = chip->irq_reg_stride; 484 420 else 485 421 d->irq_reg_stride = 1; 422 + 423 + if (chip->type_reg_stride) 424 + d->type_reg_stride = chip->type_reg_stride; 425 + else 426 + d->type_reg_stride = 1; 486 427 487 428 if (!map->use_single_read && map->reg_stride == 1 && 488 429 d->irq_reg_stride == 1) { ··· 581 512 } 582 513 } 583 514 515 + if (chip->num_type_reg) { 516 + for (i = 0; i < chip->num_irqs; i++) { 517 + reg = chip->irqs[i].type_reg_offset / map->reg_stride; 518 + d->type_buf_def[reg] |= chip->irqs[i].type_rising_mask | 519 + chip->irqs[i].type_falling_mask; 520 + } 521 + for (i = 0; i < chip->num_type_reg; ++i) { 522 + if (!d->type_buf_def[i]) 523 + continue; 524 + 525 + reg = chip->type_base + 526 + (i * map->reg_stride * d->type_reg_stride); 527 + if (chip->type_invert) 528 + ret = regmap_update_bits(map, reg, 529 + d->type_buf_def[i], 0xFF); 530 + else 531 + ret = regmap_update_bits(map, reg, 532 + d->type_buf_def[i], 0x0); 533 + if (ret != 0) { 534 + dev_err(map->dev, 535 + "Failed to set type in 0x%x: %x\n", 536 + reg, ret); 537 + goto err_alloc; 538 + } 539 + } 540 + } 541 + 584 542 if (irq_base) 585 543 d->domain = irq_domain_add_legacy(map->dev->of_node, 586 544 chip->num_irqs, irq_base, 0, ··· 638 542 err_domain: 639 543 /* Should really dispose of the domain but... */ 640 544 err_alloc: 545 + kfree(d->type_buf); 546 + kfree(d->type_buf_def); 641 547 kfree(d->wake_buf); 642 548 kfree(d->mask_buf_def); 643 549 kfree(d->mask_buf); ··· 663 565 664 566 free_irq(irq, d); 665 567 irq_domain_remove(d->domain); 568 + kfree(d->type_buf); 569 + kfree(d->type_buf_def); 666 570 kfree(d->wake_buf); 667 571 kfree(d->mask_buf_def); 668 572 kfree(d->mask_buf);
+102
drivers/base/regmap/regmap.c
··· 245 245 *(u32 *)buf = val << shift; 246 246 } 247 247 248 + #ifdef CONFIG_64BIT 249 + static void regmap_format_64_be(void *buf, unsigned int val, unsigned int shift) 250 + { 251 + __be64 *b = buf; 252 + 253 + b[0] = cpu_to_be64((u64)val << shift); 254 + } 255 + 256 + static void regmap_format_64_le(void *buf, unsigned int val, unsigned int shift) 257 + { 258 + __le64 *b = buf; 259 + 260 + b[0] = cpu_to_le64((u64)val << shift); 261 + } 262 + 263 + static void regmap_format_64_native(void *buf, unsigned int val, 264 + unsigned int shift) 265 + { 266 + *(u64 *)buf = (u64)val << shift; 267 + } 268 + #endif 269 + 248 270 static void regmap_parse_inplace_noop(void *buf) 249 271 { 250 272 } ··· 353 331 { 354 332 return *(u32 *)buf; 355 333 } 334 + 335 + #ifdef CONFIG_64BIT 336 + static unsigned int regmap_parse_64_be(const void *buf) 337 + { 338 + const __be64 *b = buf; 339 + 340 + return be64_to_cpu(b[0]); 341 + } 342 + 343 + static unsigned int regmap_parse_64_le(const void *buf) 344 + { 345 + const __le64 *b = buf; 346 + 347 + return le64_to_cpu(b[0]); 348 + } 349 + 350 + static void regmap_parse_64_be_inplace(void *buf) 351 + { 352 + __be64 *b = buf; 353 + 354 + b[0] = be64_to_cpu(b[0]); 355 + } 356 + 357 + static void regmap_parse_64_le_inplace(void *buf) 358 + { 359 + __le64 *b = buf; 360 + 361 + b[0] = le64_to_cpu(b[0]); 362 + } 363 + 364 + static unsigned int regmap_parse_64_native(const void *buf) 365 + { 366 + return *(u64 *)buf; 367 + } 368 + #endif 356 369 357 370 static void regmap_lock_mutex(void *__map) 358 371 { ··· 769 712 } 770 713 break; 771 714 715 + #ifdef CONFIG_64BIT 716 + case 64: 717 + switch (reg_endian) { 718 + case REGMAP_ENDIAN_BIG: 719 + map->format.format_reg = regmap_format_64_be; 720 + break; 721 + case REGMAP_ENDIAN_NATIVE: 722 + map->format.format_reg = regmap_format_64_native; 723 + break; 724 + default: 725 + goto err_map; 726 + } 727 + break; 728 + #endif 729 + 772 730 default: 773 731 goto err_map; 774 732 } ··· 843 771 goto err_map; 844 772 } 845 773 break; 774 + #ifdef CONFIG_64BIT 775 + case 64: 776 + switch (val_endian) { 777 + case REGMAP_ENDIAN_BIG: 778 + map->format.format_val = regmap_format_64_be; 779 + map->format.parse_val = regmap_parse_64_be; 780 + map->format.parse_inplace = regmap_parse_64_be_inplace; 781 + break; 782 + case REGMAP_ENDIAN_LITTLE: 783 + map->format.format_val = regmap_format_64_le; 784 + map->format.parse_val = regmap_parse_64_le; 785 + map->format.parse_inplace = regmap_parse_64_le_inplace; 786 + break; 787 + case REGMAP_ENDIAN_NATIVE: 788 + map->format.format_val = regmap_format_64_native; 789 + map->format.parse_val = regmap_parse_64_native; 790 + break; 791 + default: 792 + goto err_map; 793 + } 794 + break; 795 + #endif 846 796 } 847 797 848 798 if (map->format.format_write) { ··· 2582 2488 * we assume that the values are native 2583 2489 * endian. 2584 2490 */ 2491 + #ifdef CONFIG_64BIT 2492 + u64 *u64 = val; 2493 + #endif 2585 2494 u32 *u32 = val; 2586 2495 u16 *u16 = val; 2587 2496 u8 *u8 = val; 2588 2497 2589 2498 switch (map->format.val_bytes) { 2499 + #ifdef CONFIG_64BIT 2500 + case 8: 2501 + u64[i] = ival; 2502 + break; 2503 + #endif 2590 2504 case 4: 2591 2505 u32[i] = ival; 2592 2506 break;
+16
include/linux/regmap.h
··· 788 788 * 789 789 * @reg_offset: Offset of the status/mask register within the bank 790 790 * @mask: Mask used to flag/control the register. 791 + * @type_reg_offset: Offset register for the irq type setting. 792 + * @type_rising_mask: Mask bit to configure RISING type irq. 793 + * @type_falling_mask: Mask bit to configure FALLING type irq. 791 794 */ 792 795 struct regmap_irq { 793 796 unsigned int reg_offset; 794 797 unsigned int mask; 798 + unsigned int type_reg_offset; 799 + unsigned int type_rising_mask; 800 + unsigned int type_falling_mask; 795 801 }; 796 802 797 803 #define REGMAP_IRQ_REG(_irq, _off, _mask) \ ··· 817 811 * @ack_base: Base ack address. If zero then the chip is clear on read. 818 812 * Using zero value is possible with @use_ack bit. 819 813 * @wake_base: Base address for wake enables. If zero unsupported. 814 + * @type_base: Base address for irq type. If zero unsupported. 820 815 * @irq_reg_stride: Stride to use for chips where registers are not contiguous. 821 816 * @init_ack_masked: Ack all masked interrupts once during initalization. 822 817 * @mask_invert: Inverted mask register: cleared bits are masked out. 823 818 * @use_ack: Use @ack register even if it is zero. 824 819 * @ack_invert: Inverted ack register: cleared bits for ack. 825 820 * @wake_invert: Inverted wake register: cleared bits are wake enabled. 821 + * @type_invert: Invert the type flags. 826 822 * @runtime_pm: Hold a runtime PM lock on the device when accessing it. 827 823 * 828 824 * @num_regs: Number of registers in each control bank. 829 825 * @irqs: Descriptors for individual IRQs. Interrupt numbers are 830 826 * assigned based on the index in the array of the interrupt. 831 827 * @num_irqs: Number of descriptors. 828 + * @num_type_reg: Number of type registers. 829 + * @type_reg_stride: Stride to use for chips where type registers are not 830 + * contiguous. 832 831 */ 833 832 struct regmap_irq_chip { 834 833 const char *name; ··· 843 832 unsigned int unmask_base; 844 833 unsigned int ack_base; 845 834 unsigned int wake_base; 835 + unsigned int type_base; 846 836 unsigned int irq_reg_stride; 847 837 bool init_ack_masked:1; 848 838 bool mask_invert:1; ··· 851 839 bool ack_invert:1; 852 840 bool wake_invert:1; 853 841 bool runtime_pm:1; 842 + bool type_invert:1; 854 843 855 844 int num_regs; 856 845 857 846 const struct regmap_irq *irqs; 858 847 int num_irqs; 848 + 849 + int num_type_reg; 850 + unsigned int type_reg_stride; 859 851 }; 860 852 861 853 struct regmap_irq_chip_data;