1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2012-2015, 2017, 2021, The Linux Foundation. All rights reserved.
5 #include <linux/bitmap.h>
6 #include <linux/delay.h>
8 #include <linux/interrupt.h>
10 #include <linux/irqchip/chained_irq.h>
11 #include <linux/irqdomain.h>
12 #include <linux/irq.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
16 #include <linux/platform_device.h>
17 #include <linux/slab.h>
18 #include <linux/spmi.h>
20 /* PMIC Arbiter configuration registers */
21 #define PMIC_ARB_VERSION 0x0000
22 #define PMIC_ARB_VERSION_V2_MIN 0x20010000
23 #define PMIC_ARB_VERSION_V3_MIN 0x30000000
24 #define PMIC_ARB_VERSION_V5_MIN 0x50000000
25 #define PMIC_ARB_INT_EN 0x0004
27 /* PMIC Arbiter channel registers offsets */
28 #define PMIC_ARB_CMD 0x00
29 #define PMIC_ARB_CONFIG 0x04
30 #define PMIC_ARB_STATUS 0x08
31 #define PMIC_ARB_WDATA0 0x10
32 #define PMIC_ARB_WDATA1 0x14
33 #define PMIC_ARB_RDATA0 0x18
34 #define PMIC_ARB_RDATA1 0x1C
37 #define SPMI_MAPPING_TABLE_REG(N) (0x0B00 + (4 * (N)))
38 #define SPMI_MAPPING_BIT_INDEX(X) (((X) >> 18) & 0xF)
39 #define SPMI_MAPPING_BIT_IS_0_FLAG(X) (((X) >> 17) & 0x1)
40 #define SPMI_MAPPING_BIT_IS_0_RESULT(X) (((X) >> 9) & 0xFF)
41 #define SPMI_MAPPING_BIT_IS_1_FLAG(X) (((X) >> 8) & 0x1)
42 #define SPMI_MAPPING_BIT_IS_1_RESULT(X) (((X) >> 0) & 0xFF)
44 #define SPMI_MAPPING_TABLE_TREE_DEPTH 16 /* Maximum of 16-bits */
45 #define PMIC_ARB_MAX_PPID BIT(12) /* PPID is 12bit */
46 #define PMIC_ARB_APID_VALID BIT(15)
47 #define PMIC_ARB_CHAN_IS_IRQ_OWNER(reg) ((reg) & BIT(24))
48 #define INVALID_EE 0xFF
51 #define SPMI_OWNERSHIP_TABLE_REG(N) (0x0700 + (4 * (N)))
52 #define SPMI_OWNERSHIP_PERIPH2OWNER(X) ((X) & 0x7)
54 /* Channel Status fields */
55 enum pmic_arb_chnl_status {
56 PMIC_ARB_STATUS_DONE = BIT(0),
57 PMIC_ARB_STATUS_FAILURE = BIT(1),
58 PMIC_ARB_STATUS_DENIED = BIT(2),
59 PMIC_ARB_STATUS_DROPPED = BIT(3),
62 /* Command register fields */
63 #define PMIC_ARB_CMD_MAX_BYTE_COUNT 8
66 enum pmic_arb_cmd_op_code {
67 PMIC_ARB_OP_EXT_WRITEL = 0,
68 PMIC_ARB_OP_EXT_READL = 1,
69 PMIC_ARB_OP_EXT_WRITE = 2,
70 PMIC_ARB_OP_RESET = 3,
71 PMIC_ARB_OP_SLEEP = 4,
72 PMIC_ARB_OP_SHUTDOWN = 5,
73 PMIC_ARB_OP_WAKEUP = 6,
74 PMIC_ARB_OP_AUTHENTICATE = 7,
75 PMIC_ARB_OP_MSTR_READ = 8,
76 PMIC_ARB_OP_MSTR_WRITE = 9,
77 PMIC_ARB_OP_EXT_READ = 13,
78 PMIC_ARB_OP_WRITE = 14,
79 PMIC_ARB_OP_READ = 15,
80 PMIC_ARB_OP_ZERO_WRITE = 16,
84 * PMIC arbiter version 5 uses different register offsets for read/write vs
87 enum pmic_arb_channel {
92 /* Maximum number of support PMIC peripherals */
93 #define PMIC_ARB_MAX_PERIPHS 512
94 #define PMIC_ARB_TIMEOUT_US 100
95 #define PMIC_ARB_MAX_TRANS_BYTES (8)
97 #define PMIC_ARB_APID_MASK 0xFF
98 #define PMIC_ARB_PPID_MASK 0xFFF
100 /* interrupt enable bit */
101 #define SPMI_PIC_ACC_ENABLE_BIT BIT(0)
103 #define spec_to_hwirq(slave_id, periph_id, irq_id, apid) \
104 ((((slave_id) & 0xF) << 28) | \
105 (((periph_id) & 0xFF) << 20) | \
106 (((irq_id) & 0x7) << 16) | \
107 (((apid) & 0x1FF) << 0))
109 #define hwirq_to_sid(hwirq) (((hwirq) >> 28) & 0xF)
110 #define hwirq_to_per(hwirq) (((hwirq) >> 20) & 0xFF)
111 #define hwirq_to_irq(hwirq) (((hwirq) >> 16) & 0x7)
112 #define hwirq_to_apid(hwirq) (((hwirq) >> 0) & 0x1FF)
114 struct pmic_arb_ver_ops;
123 * spmi_pmic_arb - SPMI PMIC Arbiter object
125 * @rd_base: on v1 "core", on v2 "observer" register base off DT.
126 * @wr_base: on v1 "core", on v2 "chnls" register base off DT.
127 * @intr: address of the SPMI interrupt control registers.
128 * @cnfg: address of the PMIC Arbiter configuration registers.
129 * @lock: lock to synchronize accesses.
130 * @channel: execution environment channel to use for accesses.
131 * @irq: PMIC ARB interrupt.
132 * @ee: the current Execution Environment
133 * @min_apid: minimum APID (used for bounding IRQ search)
134 * @max_apid: maximum APID
135 * @mapping_table: in-memory copy of PPID -> APID mapping table.
136 * @domain: irq domain object for PMIC IRQ domain
137 * @spmic: SPMI controller object
138 * @ver_ops: version dependent operations.
139 * @ppid_to_apid in-memory copy of PPID -> APID mapping table.
141 struct spmi_pmic_arb {
142 void __iomem *rd_base;
143 void __iomem *wr_base;
147 resource_size_t core_size;
155 DECLARE_BITMAP(mapping_table_valid, PMIC_ARB_MAX_PERIPHS);
156 struct irq_domain *domain;
157 struct spmi_controller *spmic;
158 const struct pmic_arb_ver_ops *ver_ops;
161 struct apid_data apid_data[PMIC_ARB_MAX_PERIPHS];
165 * pmic_arb_ver: version dependent functionality.
167 * @ver_str: version string.
168 * @ppid_to_apid: finds the apid for a given ppid.
169 * @non_data_cmd: on v1 issues an spmi non-data command.
170 * on v2 no HW support, returns -EOPNOTSUPP.
171 * @offset: on v1 offset of per-ee channel.
172 * on v2 offset of per-ee and per-ppid channel.
173 * @fmt_cmd: formats a GENI/SPMI command.
174 * @owner_acc_status: on v1 address of PMIC_ARB_SPMI_PIC_OWNERm_ACC_STATUSn
175 * on v2 address of SPMI_PIC_OWNERm_ACC_STATUSn.
176 * @acc_enable: on v1 address of PMIC_ARB_SPMI_PIC_ACC_ENABLEn
177 * on v2 address of SPMI_PIC_ACC_ENABLEn.
178 * @irq_status: on v1 address of PMIC_ARB_SPMI_PIC_IRQ_STATUSn
179 * on v2 address of SPMI_PIC_IRQ_STATUSn.
180 * @irq_clear: on v1 address of PMIC_ARB_SPMI_PIC_IRQ_CLEARn
181 * on v2 address of SPMI_PIC_IRQ_CLEARn.
182 * @apid_map_offset: offset of PMIC_ARB_REG_CHNLn
184 struct pmic_arb_ver_ops {
186 int (*ppid_to_apid)(struct spmi_pmic_arb *pmic_arb, u16 ppid);
187 /* spmi commands (read_cmd, write_cmd, cmd) functionality */
188 int (*offset)(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr,
189 enum pmic_arb_channel ch_type);
190 u32 (*fmt_cmd)(u8 opc, u8 sid, u16 addr, u8 bc);
191 int (*non_data_cmd)(struct spmi_controller *ctrl, u8 opc, u8 sid);
192 /* Interrupts controller functionality (offset of PIC registers) */
193 void __iomem *(*owner_acc_status)(struct spmi_pmic_arb *pmic_arb, u8 m,
195 void __iomem *(*acc_enable)(struct spmi_pmic_arb *pmic_arb, u16 n);
196 void __iomem *(*irq_status)(struct spmi_pmic_arb *pmic_arb, u16 n);
197 void __iomem *(*irq_clear)(struct spmi_pmic_arb *pmic_arb, u16 n);
198 u32 (*apid_map_offset)(u16 n);
201 static inline void pmic_arb_base_write(struct spmi_pmic_arb *pmic_arb,
204 writel_relaxed(val, pmic_arb->wr_base + offset);
207 static inline void pmic_arb_set_rd_cmd(struct spmi_pmic_arb *pmic_arb,
210 writel_relaxed(val, pmic_arb->rd_base + offset);
214 * pmic_arb_read_data: reads pmic-arb's register and copy 1..4 bytes to buf
215 * @bc: byte count -1. range: 0..3
216 * @reg: register's address
217 * @buf: output parameter, length must be bc + 1
220 pmic_arb_read_data(struct spmi_pmic_arb *pmic_arb, u8 *buf, u32 reg, u8 bc)
222 u32 data = __raw_readl(pmic_arb->rd_base + reg);
224 memcpy(buf, &data, (bc & 3) + 1);
228 * pmic_arb_write_data: write 1..4 bytes from buf to pmic-arb's register
229 * @bc: byte-count -1. range: 0..3.
230 * @reg: register's address.
231 * @buf: buffer to write. length must be bc + 1.
233 static void pmic_arb_write_data(struct spmi_pmic_arb *pmic_arb, const u8 *buf,
238 memcpy(&data, buf, (bc & 3) + 1);
239 __raw_writel(data, pmic_arb->wr_base + reg);
242 static int pmic_arb_wait_for_done(struct spmi_controller *ctrl,
243 void __iomem *base, u8 sid, u16 addr,
244 enum pmic_arb_channel ch_type)
246 struct spmi_pmic_arb *pmic_arb = spmi_controller_get_drvdata(ctrl);
248 u32 timeout = PMIC_ARB_TIMEOUT_US;
252 rc = pmic_arb->ver_ops->offset(pmic_arb, sid, addr, ch_type);
257 offset += PMIC_ARB_STATUS;
260 status = readl_relaxed(base + offset);
262 if (status & PMIC_ARB_STATUS_DONE) {
263 if (status & PMIC_ARB_STATUS_DENIED) {
264 dev_err(&ctrl->dev, "%s: transaction denied (0x%x)\n",
269 if (status & PMIC_ARB_STATUS_FAILURE) {
270 dev_err(&ctrl->dev, "%s: transaction failed (0x%x)\n",
275 if (status & PMIC_ARB_STATUS_DROPPED) {
276 dev_err(&ctrl->dev, "%s: transaction dropped (0x%x)\n",
286 dev_err(&ctrl->dev, "%s: timeout, status 0x%x\n",
292 pmic_arb_non_data_cmd_v1(struct spmi_controller *ctrl, u8 opc, u8 sid)
294 struct spmi_pmic_arb *pmic_arb = spmi_controller_get_drvdata(ctrl);
300 rc = pmic_arb->ver_ops->offset(pmic_arb, sid, 0, PMIC_ARB_CHANNEL_RW);
305 cmd = ((opc | 0x40) << 27) | ((sid & 0xf) << 20);
307 raw_spin_lock_irqsave(&pmic_arb->lock, flags);
308 pmic_arb_base_write(pmic_arb, offset + PMIC_ARB_CMD, cmd);
309 rc = pmic_arb_wait_for_done(ctrl, pmic_arb->wr_base, sid, 0,
310 PMIC_ARB_CHANNEL_RW);
311 raw_spin_unlock_irqrestore(&pmic_arb->lock, flags);
317 pmic_arb_non_data_cmd_v2(struct spmi_controller *ctrl, u8 opc, u8 sid)
322 /* Non-data command */
323 static int pmic_arb_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid)
325 struct spmi_pmic_arb *pmic_arb = spmi_controller_get_drvdata(ctrl);
327 dev_dbg(&ctrl->dev, "cmd op:0x%x sid:%d\n", opc, sid);
329 /* Check for valid non-data command */
330 if (opc < SPMI_CMD_RESET || opc > SPMI_CMD_WAKEUP)
333 return pmic_arb->ver_ops->non_data_cmd(ctrl, opc, sid);
336 static int pmic_arb_read_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
337 u16 addr, u8 *buf, size_t len)
339 struct spmi_pmic_arb *pmic_arb = spmi_controller_get_drvdata(ctrl);
346 rc = pmic_arb->ver_ops->offset(pmic_arb, sid, addr,
347 PMIC_ARB_CHANNEL_OBS);
352 if (bc >= PMIC_ARB_MAX_TRANS_BYTES) {
353 dev_err(&ctrl->dev, "pmic-arb supports 1..%d bytes per trans, but:%zu requested",
354 PMIC_ARB_MAX_TRANS_BYTES, len);
358 /* Check the opcode */
359 if (opc >= 0x60 && opc <= 0x7F)
360 opc = PMIC_ARB_OP_READ;
361 else if (opc >= 0x20 && opc <= 0x2F)
362 opc = PMIC_ARB_OP_EXT_READ;
363 else if (opc >= 0x38 && opc <= 0x3F)
364 opc = PMIC_ARB_OP_EXT_READL;
368 cmd = pmic_arb->ver_ops->fmt_cmd(opc, sid, addr, bc);
370 raw_spin_lock_irqsave(&pmic_arb->lock, flags);
371 pmic_arb_set_rd_cmd(pmic_arb, offset + PMIC_ARB_CMD, cmd);
372 rc = pmic_arb_wait_for_done(ctrl, pmic_arb->rd_base, sid, addr,
373 PMIC_ARB_CHANNEL_OBS);
377 pmic_arb_read_data(pmic_arb, buf, offset + PMIC_ARB_RDATA0,
381 pmic_arb_read_data(pmic_arb, buf + 4, offset + PMIC_ARB_RDATA1,
385 raw_spin_unlock_irqrestore(&pmic_arb->lock, flags);
389 static int pmic_arb_write_cmd(struct spmi_controller *ctrl, u8 opc, u8 sid,
390 u16 addr, const u8 *buf, size_t len)
392 struct spmi_pmic_arb *pmic_arb = spmi_controller_get_drvdata(ctrl);
399 rc = pmic_arb->ver_ops->offset(pmic_arb, sid, addr,
400 PMIC_ARB_CHANNEL_RW);
405 if (bc >= PMIC_ARB_MAX_TRANS_BYTES) {
406 dev_err(&ctrl->dev, "pmic-arb supports 1..%d bytes per trans, but:%zu requested",
407 PMIC_ARB_MAX_TRANS_BYTES, len);
411 /* Check the opcode */
412 if (opc >= 0x40 && opc <= 0x5F)
413 opc = PMIC_ARB_OP_WRITE;
414 else if (opc <= 0x0F)
415 opc = PMIC_ARB_OP_EXT_WRITE;
416 else if (opc >= 0x30 && opc <= 0x37)
417 opc = PMIC_ARB_OP_EXT_WRITEL;
418 else if (opc >= 0x80)
419 opc = PMIC_ARB_OP_ZERO_WRITE;
423 cmd = pmic_arb->ver_ops->fmt_cmd(opc, sid, addr, bc);
425 /* Write data to FIFOs */
426 raw_spin_lock_irqsave(&pmic_arb->lock, flags);
427 pmic_arb_write_data(pmic_arb, buf, offset + PMIC_ARB_WDATA0,
430 pmic_arb_write_data(pmic_arb, buf + 4, offset + PMIC_ARB_WDATA1,
433 /* Start the transaction */
434 pmic_arb_base_write(pmic_arb, offset + PMIC_ARB_CMD, cmd);
435 rc = pmic_arb_wait_for_done(ctrl, pmic_arb->wr_base, sid, addr,
436 PMIC_ARB_CHANNEL_RW);
437 raw_spin_unlock_irqrestore(&pmic_arb->lock, flags);
443 QPNPINT_REG_RT_STS = 0x10,
444 QPNPINT_REG_SET_TYPE = 0x11,
445 QPNPINT_REG_POLARITY_HIGH = 0x12,
446 QPNPINT_REG_POLARITY_LOW = 0x13,
447 QPNPINT_REG_LATCHED_CLR = 0x14,
448 QPNPINT_REG_EN_SET = 0x15,
449 QPNPINT_REG_EN_CLR = 0x16,
450 QPNPINT_REG_LATCHED_STS = 0x18,
453 struct spmi_pmic_arb_qpnpint_type {
454 u8 type; /* 1 -> edge */
459 /* Simplified accessor functions for irqchip callbacks */
460 static void qpnpint_spmi_write(struct irq_data *d, u8 reg, void *buf,
463 struct spmi_pmic_arb *pmic_arb = irq_data_get_irq_chip_data(d);
464 u8 sid = hwirq_to_sid(d->hwirq);
465 u8 per = hwirq_to_per(d->hwirq);
467 if (pmic_arb_write_cmd(pmic_arb->spmic, SPMI_CMD_EXT_WRITEL, sid,
468 (per << 8) + reg, buf, len))
469 dev_err_ratelimited(&pmic_arb->spmic->dev, "failed irqchip transaction on %x\n",
473 static void qpnpint_spmi_read(struct irq_data *d, u8 reg, void *buf, size_t len)
475 struct spmi_pmic_arb *pmic_arb = irq_data_get_irq_chip_data(d);
476 u8 sid = hwirq_to_sid(d->hwirq);
477 u8 per = hwirq_to_per(d->hwirq);
479 if (pmic_arb_read_cmd(pmic_arb->spmic, SPMI_CMD_EXT_READL, sid,
480 (per << 8) + reg, buf, len))
481 dev_err_ratelimited(&pmic_arb->spmic->dev, "failed irqchip transaction on %x\n",
485 static void cleanup_irq(struct spmi_pmic_arb *pmic_arb, u16 apid, int id)
487 u16 ppid = pmic_arb->apid_data[apid].ppid;
489 u8 per = ppid & 0xFF;
490 u8 irq_mask = BIT(id);
492 writel_relaxed(irq_mask, pmic_arb->ver_ops->irq_clear(pmic_arb, apid));
494 if (pmic_arb_write_cmd(pmic_arb->spmic, SPMI_CMD_EXT_WRITEL, sid,
495 (per << 8) + QPNPINT_REG_LATCHED_CLR, &irq_mask, 1))
496 dev_err_ratelimited(&pmic_arb->spmic->dev, "failed to ack irq_mask = 0x%x for ppid = %x\n",
499 if (pmic_arb_write_cmd(pmic_arb->spmic, SPMI_CMD_EXT_WRITEL, sid,
500 (per << 8) + QPNPINT_REG_EN_CLR, &irq_mask, 1))
501 dev_err_ratelimited(&pmic_arb->spmic->dev, "failed to ack irq_mask = 0x%x for ppid = %x\n",
505 static void periph_interrupt(struct spmi_pmic_arb *pmic_arb, u16 apid)
509 u8 sid = (pmic_arb->apid_data[apid].ppid >> 8) & 0xF;
510 u8 per = pmic_arb->apid_data[apid].ppid & 0xFF;
512 status = readl_relaxed(pmic_arb->ver_ops->irq_status(pmic_arb, apid));
514 id = ffs(status) - 1;
516 irq = irq_find_mapping(pmic_arb->domain,
517 spec_to_hwirq(sid, per, id, apid));
519 cleanup_irq(pmic_arb, apid, id);
522 generic_handle_irq(irq);
526 static void pmic_arb_chained_irq(struct irq_desc *desc)
528 struct spmi_pmic_arb *pmic_arb = irq_desc_get_handler_data(desc);
529 const struct pmic_arb_ver_ops *ver_ops = pmic_arb->ver_ops;
530 struct irq_chip *chip = irq_desc_get_chip(desc);
531 int first = pmic_arb->min_apid >> 5;
532 int last = pmic_arb->max_apid >> 5;
533 u8 ee = pmic_arb->ee;
537 chained_irq_enter(chip, desc);
539 for (i = first; i <= last; ++i) {
540 status = readl_relaxed(
541 ver_ops->owner_acc_status(pmic_arb, ee, i));
543 id = ffs(status) - 1;
546 enable = readl_relaxed(
547 ver_ops->acc_enable(pmic_arb, apid));
548 if (enable & SPMI_PIC_ACC_ENABLE_BIT)
549 periph_interrupt(pmic_arb, apid);
553 chained_irq_exit(chip, desc);
556 static void qpnpint_irq_ack(struct irq_data *d)
558 struct spmi_pmic_arb *pmic_arb = irq_data_get_irq_chip_data(d);
559 u8 irq = hwirq_to_irq(d->hwirq);
560 u16 apid = hwirq_to_apid(d->hwirq);
563 writel_relaxed(BIT(irq), pmic_arb->ver_ops->irq_clear(pmic_arb, apid));
566 qpnpint_spmi_write(d, QPNPINT_REG_LATCHED_CLR, &data, 1);
569 static void qpnpint_irq_mask(struct irq_data *d)
571 u8 irq = hwirq_to_irq(d->hwirq);
574 qpnpint_spmi_write(d, QPNPINT_REG_EN_CLR, &data, 1);
577 static void qpnpint_irq_unmask(struct irq_data *d)
579 struct spmi_pmic_arb *pmic_arb = irq_data_get_irq_chip_data(d);
580 const struct pmic_arb_ver_ops *ver_ops = pmic_arb->ver_ops;
581 u8 irq = hwirq_to_irq(d->hwirq);
582 u16 apid = hwirq_to_apid(d->hwirq);
585 writel_relaxed(SPMI_PIC_ACC_ENABLE_BIT,
586 ver_ops->acc_enable(pmic_arb, apid));
588 qpnpint_spmi_read(d, QPNPINT_REG_EN_SET, &buf[0], 1);
589 if (!(buf[0] & BIT(irq))) {
591 * Since the interrupt is currently disabled, write to both the
592 * LATCHED_CLR and EN_SET registers so that a spurious interrupt
593 * cannot be triggered when the interrupt is enabled
597 qpnpint_spmi_write(d, QPNPINT_REG_LATCHED_CLR, &buf, 2);
601 static int qpnpint_irq_set_type(struct irq_data *d, unsigned int flow_type)
603 struct spmi_pmic_arb_qpnpint_type type;
604 irq_flow_handler_t flow_handler;
605 u8 irq = hwirq_to_irq(d->hwirq);
607 qpnpint_spmi_read(d, QPNPINT_REG_SET_TYPE, &type, sizeof(type));
609 if (flow_type & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) {
610 type.type |= BIT(irq);
611 if (flow_type & IRQF_TRIGGER_RISING)
612 type.polarity_high |= BIT(irq);
613 if (flow_type & IRQF_TRIGGER_FALLING)
614 type.polarity_low |= BIT(irq);
616 flow_handler = handle_edge_irq;
618 if ((flow_type & (IRQF_TRIGGER_HIGH)) &&
619 (flow_type & (IRQF_TRIGGER_LOW)))
622 type.type &= ~BIT(irq); /* level trig */
623 if (flow_type & IRQF_TRIGGER_HIGH)
624 type.polarity_high |= BIT(irq);
626 type.polarity_low |= BIT(irq);
628 flow_handler = handle_level_irq;
631 qpnpint_spmi_write(d, QPNPINT_REG_SET_TYPE, &type, sizeof(type));
632 irq_set_handler_locked(d, flow_handler);
637 static int qpnpint_irq_set_wake(struct irq_data *d, unsigned int on)
639 struct spmi_pmic_arb *pmic_arb = irq_data_get_irq_chip_data(d);
641 return irq_set_irq_wake(pmic_arb->irq, on);
644 static int qpnpint_get_irqchip_state(struct irq_data *d,
645 enum irqchip_irq_state which,
648 u8 irq = hwirq_to_irq(d->hwirq);
651 if (which != IRQCHIP_STATE_LINE_LEVEL)
654 qpnpint_spmi_read(d, QPNPINT_REG_RT_STS, &status, 1);
655 *state = !!(status & BIT(irq));
660 static int qpnpint_irq_domain_activate(struct irq_domain *domain,
661 struct irq_data *d, bool reserve)
663 struct spmi_pmic_arb *pmic_arb = irq_data_get_irq_chip_data(d);
664 u16 periph = hwirq_to_per(d->hwirq);
665 u16 apid = hwirq_to_apid(d->hwirq);
666 u16 sid = hwirq_to_sid(d->hwirq);
667 u16 irq = hwirq_to_irq(d->hwirq);
669 if (pmic_arb->apid_data[apid].irq_ee != pmic_arb->ee) {
670 dev_err(&pmic_arb->spmic->dev, "failed to xlate sid = %#x, periph = %#x, irq = %u: ee=%u but owner=%u\n",
671 sid, periph, irq, pmic_arb->ee,
672 pmic_arb->apid_data[apid].irq_ee);
679 static struct irq_chip pmic_arb_irqchip = {
681 .irq_ack = qpnpint_irq_ack,
682 .irq_mask = qpnpint_irq_mask,
683 .irq_unmask = qpnpint_irq_unmask,
684 .irq_set_type = qpnpint_irq_set_type,
685 .irq_set_wake = qpnpint_irq_set_wake,
686 .irq_get_irqchip_state = qpnpint_get_irqchip_state,
687 .flags = IRQCHIP_MASK_ON_SUSPEND,
690 static int qpnpint_irq_domain_translate(struct irq_domain *d,
691 struct irq_fwspec *fwspec,
692 unsigned long *out_hwirq,
693 unsigned int *out_type)
695 struct spmi_pmic_arb *pmic_arb = d->host_data;
696 u32 *intspec = fwspec->param;
700 dev_dbg(&pmic_arb->spmic->dev, "intspec[0] 0x%1x intspec[1] 0x%02x intspec[2] 0x%02x\n",
701 intspec[0], intspec[1], intspec[2]);
703 if (irq_domain_get_of_node(d) != pmic_arb->spmic->dev.of_node)
705 if (fwspec->param_count != 4)
707 if (intspec[0] > 0xF || intspec[1] > 0xFF || intspec[2] > 0x7)
710 ppid = intspec[0] << 8 | intspec[1];
711 rc = pmic_arb->ver_ops->ppid_to_apid(pmic_arb, ppid);
713 dev_err(&pmic_arb->spmic->dev, "failed to xlate sid = %#x, periph = %#x, irq = %u rc = %d\n",
714 intspec[0], intspec[1], intspec[2], rc);
719 /* Keep track of {max,min}_apid for bounding search during interrupt */
720 if (apid > pmic_arb->max_apid)
721 pmic_arb->max_apid = apid;
722 if (apid < pmic_arb->min_apid)
723 pmic_arb->min_apid = apid;
725 *out_hwirq = spec_to_hwirq(intspec[0], intspec[1], intspec[2], apid);
726 *out_type = intspec[3] & IRQ_TYPE_SENSE_MASK;
728 dev_dbg(&pmic_arb->spmic->dev, "out_hwirq = %lu\n", *out_hwirq);
733 static struct lock_class_key qpnpint_irq_lock_class, qpnpint_irq_request_class;
735 static void qpnpint_irq_domain_map(struct spmi_pmic_arb *pmic_arb,
736 struct irq_domain *domain, unsigned int virq,
737 irq_hw_number_t hwirq, unsigned int type)
739 irq_flow_handler_t handler;
741 dev_dbg(&pmic_arb->spmic->dev, "virq = %u, hwirq = %lu, type = %u\n",
744 if (type & IRQ_TYPE_EDGE_BOTH)
745 handler = handle_edge_irq;
747 handler = handle_level_irq;
750 irq_set_lockdep_class(virq, &qpnpint_irq_lock_class,
751 &qpnpint_irq_request_class);
752 irq_domain_set_info(domain, virq, hwirq, &pmic_arb_irqchip, pmic_arb,
753 handler, NULL, NULL);
756 static int qpnpint_irq_domain_alloc(struct irq_domain *domain,
757 unsigned int virq, unsigned int nr_irqs,
760 struct spmi_pmic_arb *pmic_arb = domain->host_data;
761 struct irq_fwspec *fwspec = data;
762 irq_hw_number_t hwirq;
766 ret = qpnpint_irq_domain_translate(domain, fwspec, &hwirq, &type);
770 for (i = 0; i < nr_irqs; i++)
771 qpnpint_irq_domain_map(pmic_arb, domain, virq + i, hwirq + i,
777 static int pmic_arb_ppid_to_apid_v1(struct spmi_pmic_arb *pmic_arb, u16 ppid)
779 u32 *mapping_table = pmic_arb->mapping_table;
785 apid_valid = pmic_arb->ppid_to_apid[ppid];
786 if (apid_valid & PMIC_ARB_APID_VALID) {
787 apid = apid_valid & ~PMIC_ARB_APID_VALID;
791 for (i = 0; i < SPMI_MAPPING_TABLE_TREE_DEPTH; ++i) {
792 if (!test_and_set_bit(index, pmic_arb->mapping_table_valid))
793 mapping_table[index] = readl_relaxed(pmic_arb->cnfg +
794 SPMI_MAPPING_TABLE_REG(index));
796 data = mapping_table[index];
798 if (ppid & BIT(SPMI_MAPPING_BIT_INDEX(data))) {
799 if (SPMI_MAPPING_BIT_IS_1_FLAG(data)) {
800 index = SPMI_MAPPING_BIT_IS_1_RESULT(data);
802 apid = SPMI_MAPPING_BIT_IS_1_RESULT(data);
803 pmic_arb->ppid_to_apid[ppid]
804 = apid | PMIC_ARB_APID_VALID;
805 pmic_arb->apid_data[apid].ppid = ppid;
809 if (SPMI_MAPPING_BIT_IS_0_FLAG(data)) {
810 index = SPMI_MAPPING_BIT_IS_0_RESULT(data);
812 apid = SPMI_MAPPING_BIT_IS_0_RESULT(data);
813 pmic_arb->ppid_to_apid[ppid]
814 = apid | PMIC_ARB_APID_VALID;
815 pmic_arb->apid_data[apid].ppid = ppid;
824 /* v1 offset per ee */
825 static int pmic_arb_offset_v1(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr,
826 enum pmic_arb_channel ch_type)
828 return 0x800 + 0x80 * pmic_arb->channel;
831 static u16 pmic_arb_find_apid(struct spmi_pmic_arb *pmic_arb, u16 ppid)
833 struct apid_data *apidd = &pmic_arb->apid_data[pmic_arb->last_apid];
837 for (apid = pmic_arb->last_apid; ; apid++, apidd++) {
838 offset = pmic_arb->ver_ops->apid_map_offset(apid);
839 if (offset >= pmic_arb->core_size)
842 regval = readl_relaxed(pmic_arb->cnfg +
843 SPMI_OWNERSHIP_TABLE_REG(apid));
844 apidd->irq_ee = SPMI_OWNERSHIP_PERIPH2OWNER(regval);
845 apidd->write_ee = apidd->irq_ee;
847 regval = readl_relaxed(pmic_arb->core + offset);
851 id = (regval >> 8) & PMIC_ARB_PPID_MASK;
852 pmic_arb->ppid_to_apid[id] = apid | PMIC_ARB_APID_VALID;
855 apid |= PMIC_ARB_APID_VALID;
859 pmic_arb->last_apid = apid & ~PMIC_ARB_APID_VALID;
864 static int pmic_arb_ppid_to_apid_v2(struct spmi_pmic_arb *pmic_arb, u16 ppid)
868 apid_valid = pmic_arb->ppid_to_apid[ppid];
869 if (!(apid_valid & PMIC_ARB_APID_VALID))
870 apid_valid = pmic_arb_find_apid(pmic_arb, ppid);
871 if (!(apid_valid & PMIC_ARB_APID_VALID))
874 return apid_valid & ~PMIC_ARB_APID_VALID;
877 static int pmic_arb_read_apid_map_v5(struct spmi_pmic_arb *pmic_arb)
879 struct apid_data *apidd = pmic_arb->apid_data;
880 struct apid_data *prev_apidd;
882 bool valid, is_irq_ee;
886 * In order to allow multiple EEs to write to a single PPID in arbiter
887 * version 5, there is more than one APID mapped to each PPID.
888 * The owner field for each of these mappings specifies the EE which is
889 * allowed to write to the APID. The owner of the last (highest) APID
890 * for a given PPID will receive interrupts from the PPID.
892 for (i = 0; ; i++, apidd++) {
893 offset = pmic_arb->ver_ops->apid_map_offset(i);
894 if (offset >= pmic_arb->core_size)
897 regval = readl_relaxed(pmic_arb->core + offset);
900 ppid = (regval >> 8) & PMIC_ARB_PPID_MASK;
901 is_irq_ee = PMIC_ARB_CHAN_IS_IRQ_OWNER(regval);
903 regval = readl_relaxed(pmic_arb->cnfg +
904 SPMI_OWNERSHIP_TABLE_REG(i));
905 apidd->write_ee = SPMI_OWNERSHIP_PERIPH2OWNER(regval);
907 apidd->irq_ee = is_irq_ee ? apidd->write_ee : INVALID_EE;
909 valid = pmic_arb->ppid_to_apid[ppid] & PMIC_ARB_APID_VALID;
910 apid = pmic_arb->ppid_to_apid[ppid] & ~PMIC_ARB_APID_VALID;
911 prev_apidd = &pmic_arb->apid_data[apid];
913 if (valid && is_irq_ee &&
914 prev_apidd->write_ee == pmic_arb->ee) {
916 * Duplicate PPID mapping after the one for this EE;
917 * override the irq owner
919 prev_apidd->irq_ee = apidd->irq_ee;
920 } else if (!valid || is_irq_ee) {
921 /* First PPID mapping or duplicate for another EE */
922 pmic_arb->ppid_to_apid[ppid] = i | PMIC_ARB_APID_VALID;
926 pmic_arb->last_apid = i;
929 /* Dump the mapping table for debug purposes. */
930 dev_dbg(&pmic_arb->spmic->dev, "PPID APID Write-EE IRQ-EE\n");
931 for (ppid = 0; ppid < PMIC_ARB_MAX_PPID; ppid++) {
932 apid = pmic_arb->ppid_to_apid[ppid];
933 if (apid & PMIC_ARB_APID_VALID) {
934 apid &= ~PMIC_ARB_APID_VALID;
935 apidd = &pmic_arb->apid_data[apid];
936 dev_dbg(&pmic_arb->spmic->dev, "%#03X %3u %2u %2u\n",
937 ppid, apid, apidd->write_ee, apidd->irq_ee);
944 static int pmic_arb_ppid_to_apid_v5(struct spmi_pmic_arb *pmic_arb, u16 ppid)
946 if (!(pmic_arb->ppid_to_apid[ppid] & PMIC_ARB_APID_VALID))
949 return pmic_arb->ppid_to_apid[ppid] & ~PMIC_ARB_APID_VALID;
952 /* v2 offset per ppid and per ee */
953 static int pmic_arb_offset_v2(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr,
954 enum pmic_arb_channel ch_type)
960 ppid = sid << 8 | ((addr >> 8) & 0xFF);
961 rc = pmic_arb_ppid_to_apid_v2(pmic_arb, ppid);
966 return 0x1000 * pmic_arb->ee + 0x8000 * apid;
970 * v5 offset per ee and per apid for observer channels and per apid for
971 * read/write channels.
973 static int pmic_arb_offset_v5(struct spmi_pmic_arb *pmic_arb, u8 sid, u16 addr,
974 enum pmic_arb_channel ch_type)
979 u16 ppid = (sid << 8) | (addr >> 8);
981 rc = pmic_arb_ppid_to_apid_v5(pmic_arb, ppid);
987 case PMIC_ARB_CHANNEL_OBS:
988 offset = 0x10000 * pmic_arb->ee + 0x80 * apid;
990 case PMIC_ARB_CHANNEL_RW:
991 offset = 0x10000 * apid;
998 static u32 pmic_arb_fmt_cmd_v1(u8 opc, u8 sid, u16 addr, u8 bc)
1000 return (opc << 27) | ((sid & 0xf) << 20) | (addr << 4) | (bc & 0x7);
1003 static u32 pmic_arb_fmt_cmd_v2(u8 opc, u8 sid, u16 addr, u8 bc)
1005 return (opc << 27) | ((addr & 0xff) << 4) | (bc & 0x7);
1008 static void __iomem *
1009 pmic_arb_owner_acc_status_v1(struct spmi_pmic_arb *pmic_arb, u8 m, u16 n)
1011 return pmic_arb->intr + 0x20 * m + 0x4 * n;
1014 static void __iomem *
1015 pmic_arb_owner_acc_status_v2(struct spmi_pmic_arb *pmic_arb, u8 m, u16 n)
1017 return pmic_arb->intr + 0x100000 + 0x1000 * m + 0x4 * n;
1020 static void __iomem *
1021 pmic_arb_owner_acc_status_v3(struct spmi_pmic_arb *pmic_arb, u8 m, u16 n)
1023 return pmic_arb->intr + 0x200000 + 0x1000 * m + 0x4 * n;
1026 static void __iomem *
1027 pmic_arb_owner_acc_status_v5(struct spmi_pmic_arb *pmic_arb, u8 m, u16 n)
1029 return pmic_arb->intr + 0x10000 * m + 0x4 * n;
1032 static void __iomem *
1033 pmic_arb_acc_enable_v1(struct spmi_pmic_arb *pmic_arb, u16 n)
1035 return pmic_arb->intr + 0x200 + 0x4 * n;
1038 static void __iomem *
1039 pmic_arb_acc_enable_v2(struct spmi_pmic_arb *pmic_arb, u16 n)
1041 return pmic_arb->intr + 0x1000 * n;
1044 static void __iomem *
1045 pmic_arb_acc_enable_v5(struct spmi_pmic_arb *pmic_arb, u16 n)
1047 return pmic_arb->wr_base + 0x100 + 0x10000 * n;
1050 static void __iomem *
1051 pmic_arb_irq_status_v1(struct spmi_pmic_arb *pmic_arb, u16 n)
1053 return pmic_arb->intr + 0x600 + 0x4 * n;
1056 static void __iomem *
1057 pmic_arb_irq_status_v2(struct spmi_pmic_arb *pmic_arb, u16 n)
1059 return pmic_arb->intr + 0x4 + 0x1000 * n;
1062 static void __iomem *
1063 pmic_arb_irq_status_v5(struct spmi_pmic_arb *pmic_arb, u16 n)
1065 return pmic_arb->wr_base + 0x104 + 0x10000 * n;
1068 static void __iomem *
1069 pmic_arb_irq_clear_v1(struct spmi_pmic_arb *pmic_arb, u16 n)
1071 return pmic_arb->intr + 0xA00 + 0x4 * n;
1074 static void __iomem *
1075 pmic_arb_irq_clear_v2(struct spmi_pmic_arb *pmic_arb, u16 n)
1077 return pmic_arb->intr + 0x8 + 0x1000 * n;
1080 static void __iomem *
1081 pmic_arb_irq_clear_v5(struct spmi_pmic_arb *pmic_arb, u16 n)
1083 return pmic_arb->wr_base + 0x108 + 0x10000 * n;
1086 static u32 pmic_arb_apid_map_offset_v2(u16 n)
1088 return 0x800 + 0x4 * n;
1091 static u32 pmic_arb_apid_map_offset_v5(u16 n)
1093 return 0x900 + 0x4 * n;
1096 static const struct pmic_arb_ver_ops pmic_arb_v1 = {
1098 .ppid_to_apid = pmic_arb_ppid_to_apid_v1,
1099 .non_data_cmd = pmic_arb_non_data_cmd_v1,
1100 .offset = pmic_arb_offset_v1,
1101 .fmt_cmd = pmic_arb_fmt_cmd_v1,
1102 .owner_acc_status = pmic_arb_owner_acc_status_v1,
1103 .acc_enable = pmic_arb_acc_enable_v1,
1104 .irq_status = pmic_arb_irq_status_v1,
1105 .irq_clear = pmic_arb_irq_clear_v1,
1106 .apid_map_offset = pmic_arb_apid_map_offset_v2,
1109 static const struct pmic_arb_ver_ops pmic_arb_v2 = {
1111 .ppid_to_apid = pmic_arb_ppid_to_apid_v2,
1112 .non_data_cmd = pmic_arb_non_data_cmd_v2,
1113 .offset = pmic_arb_offset_v2,
1114 .fmt_cmd = pmic_arb_fmt_cmd_v2,
1115 .owner_acc_status = pmic_arb_owner_acc_status_v2,
1116 .acc_enable = pmic_arb_acc_enable_v2,
1117 .irq_status = pmic_arb_irq_status_v2,
1118 .irq_clear = pmic_arb_irq_clear_v2,
1119 .apid_map_offset = pmic_arb_apid_map_offset_v2,
1122 static const struct pmic_arb_ver_ops pmic_arb_v3 = {
1124 .ppid_to_apid = pmic_arb_ppid_to_apid_v2,
1125 .non_data_cmd = pmic_arb_non_data_cmd_v2,
1126 .offset = pmic_arb_offset_v2,
1127 .fmt_cmd = pmic_arb_fmt_cmd_v2,
1128 .owner_acc_status = pmic_arb_owner_acc_status_v3,
1129 .acc_enable = pmic_arb_acc_enable_v2,
1130 .irq_status = pmic_arb_irq_status_v2,
1131 .irq_clear = pmic_arb_irq_clear_v2,
1132 .apid_map_offset = pmic_arb_apid_map_offset_v2,
1135 static const struct pmic_arb_ver_ops pmic_arb_v5 = {
1137 .ppid_to_apid = pmic_arb_ppid_to_apid_v5,
1138 .non_data_cmd = pmic_arb_non_data_cmd_v2,
1139 .offset = pmic_arb_offset_v5,
1140 .fmt_cmd = pmic_arb_fmt_cmd_v2,
1141 .owner_acc_status = pmic_arb_owner_acc_status_v5,
1142 .acc_enable = pmic_arb_acc_enable_v5,
1143 .irq_status = pmic_arb_irq_status_v5,
1144 .irq_clear = pmic_arb_irq_clear_v5,
1145 .apid_map_offset = pmic_arb_apid_map_offset_v5,
1148 static const struct irq_domain_ops pmic_arb_irq_domain_ops = {
1149 .activate = qpnpint_irq_domain_activate,
1150 .alloc = qpnpint_irq_domain_alloc,
1151 .free = irq_domain_free_irqs_common,
1152 .translate = qpnpint_irq_domain_translate,
1155 static int spmi_pmic_arb_probe(struct platform_device *pdev)
1157 struct spmi_pmic_arb *pmic_arb;
1158 struct spmi_controller *ctrl;
1159 struct resource *res;
1162 u32 channel, ee, hw_ver;
1165 ctrl = spmi_controller_alloc(&pdev->dev, sizeof(*pmic_arb));
1169 pmic_arb = spmi_controller_get_drvdata(ctrl);
1170 pmic_arb->spmic = ctrl;
1172 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core");
1173 core = devm_ioremap_resource(&ctrl->dev, res);
1175 err = PTR_ERR(core);
1179 pmic_arb->core_size = resource_size(res);
1181 pmic_arb->ppid_to_apid = devm_kcalloc(&ctrl->dev, PMIC_ARB_MAX_PPID,
1182 sizeof(*pmic_arb->ppid_to_apid),
1184 if (!pmic_arb->ppid_to_apid) {
1189 hw_ver = readl_relaxed(core + PMIC_ARB_VERSION);
1191 if (hw_ver < PMIC_ARB_VERSION_V2_MIN) {
1192 pmic_arb->ver_ops = &pmic_arb_v1;
1193 pmic_arb->wr_base = core;
1194 pmic_arb->rd_base = core;
1196 pmic_arb->core = core;
1198 if (hw_ver < PMIC_ARB_VERSION_V3_MIN)
1199 pmic_arb->ver_ops = &pmic_arb_v2;
1200 else if (hw_ver < PMIC_ARB_VERSION_V5_MIN)
1201 pmic_arb->ver_ops = &pmic_arb_v3;
1203 pmic_arb->ver_ops = &pmic_arb_v5;
1205 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1207 pmic_arb->rd_base = devm_ioremap_resource(&ctrl->dev, res);
1208 if (IS_ERR(pmic_arb->rd_base)) {
1209 err = PTR_ERR(pmic_arb->rd_base);
1213 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1215 pmic_arb->wr_base = devm_ioremap_resource(&ctrl->dev, res);
1216 if (IS_ERR(pmic_arb->wr_base)) {
1217 err = PTR_ERR(pmic_arb->wr_base);
1222 dev_info(&ctrl->dev, "PMIC arbiter version %s (0x%x)\n",
1223 pmic_arb->ver_ops->ver_str, hw_ver);
1225 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "intr");
1226 pmic_arb->intr = devm_ioremap_resource(&ctrl->dev, res);
1227 if (IS_ERR(pmic_arb->intr)) {
1228 err = PTR_ERR(pmic_arb->intr);
1232 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cnfg");
1233 pmic_arb->cnfg = devm_ioremap_resource(&ctrl->dev, res);
1234 if (IS_ERR(pmic_arb->cnfg)) {
1235 err = PTR_ERR(pmic_arb->cnfg);
1239 pmic_arb->irq = platform_get_irq_byname(pdev, "periph_irq");
1240 if (pmic_arb->irq < 0) {
1241 err = pmic_arb->irq;
1245 err = of_property_read_u32(pdev->dev.of_node, "qcom,channel", &channel);
1247 dev_err(&pdev->dev, "channel unspecified.\n");
1252 dev_err(&pdev->dev, "invalid channel (%u) specified.\n",
1258 pmic_arb->channel = channel;
1260 err = of_property_read_u32(pdev->dev.of_node, "qcom,ee", &ee);
1262 dev_err(&pdev->dev, "EE unspecified.\n");
1267 dev_err(&pdev->dev, "invalid EE (%u) specified\n", ee);
1273 mapping_table = devm_kcalloc(&ctrl->dev, PMIC_ARB_MAX_PERIPHS,
1274 sizeof(*mapping_table), GFP_KERNEL);
1275 if (!mapping_table) {
1280 pmic_arb->mapping_table = mapping_table;
1281 /* Initialize max_apid/min_apid to the opposite bounds, during
1282 * the irq domain translation, we are sure to update these */
1283 pmic_arb->max_apid = 0;
1284 pmic_arb->min_apid = PMIC_ARB_MAX_PERIPHS - 1;
1286 platform_set_drvdata(pdev, ctrl);
1287 raw_spin_lock_init(&pmic_arb->lock);
1289 ctrl->cmd = pmic_arb_cmd;
1290 ctrl->read_cmd = pmic_arb_read_cmd;
1291 ctrl->write_cmd = pmic_arb_write_cmd;
1293 if (hw_ver >= PMIC_ARB_VERSION_V5_MIN) {
1294 err = pmic_arb_read_apid_map_v5(pmic_arb);
1296 dev_err(&pdev->dev, "could not read APID->PPID mapping table, rc= %d\n",
1302 dev_dbg(&pdev->dev, "adding irq domain\n");
1303 pmic_arb->domain = irq_domain_add_tree(pdev->dev.of_node,
1304 &pmic_arb_irq_domain_ops, pmic_arb);
1305 if (!pmic_arb->domain) {
1306 dev_err(&pdev->dev, "unable to create irq_domain\n");
1311 irq_set_chained_handler_and_data(pmic_arb->irq, pmic_arb_chained_irq,
1313 err = spmi_controller_add(ctrl);
1315 goto err_domain_remove;
1320 irq_set_chained_handler_and_data(pmic_arb->irq, NULL, NULL);
1321 irq_domain_remove(pmic_arb->domain);
1323 spmi_controller_put(ctrl);
1327 static int spmi_pmic_arb_remove(struct platform_device *pdev)
1329 struct spmi_controller *ctrl = platform_get_drvdata(pdev);
1330 struct spmi_pmic_arb *pmic_arb = spmi_controller_get_drvdata(ctrl);
1331 spmi_controller_remove(ctrl);
1332 irq_set_chained_handler_and_data(pmic_arb->irq, NULL, NULL);
1333 irq_domain_remove(pmic_arb->domain);
1334 spmi_controller_put(ctrl);
1338 static const struct of_device_id spmi_pmic_arb_match_table[] = {
1339 { .compatible = "qcom,spmi-pmic-arb", },
1342 MODULE_DEVICE_TABLE(of, spmi_pmic_arb_match_table);
1344 static struct platform_driver spmi_pmic_arb_driver = {
1345 .probe = spmi_pmic_arb_probe,
1346 .remove = spmi_pmic_arb_remove,
1348 .name = "spmi_pmic_arb",
1349 .of_match_table = spmi_pmic_arb_match_table,
1352 module_platform_driver(spmi_pmic_arb_driver);
1354 MODULE_LICENSE("GPL v2");
1355 MODULE_ALIAS("platform:spmi_pmic_arb");