28 Aug, 2017

14 commits

  • Check the irq ownership in the irq_request_resources callback
    instead of checking it during the irq mapping. This can prevent
    installing the flow handler for the interrupt that is not owned by the EE
    and allow the irq translation during the gpio driver probe.

    Signed-off-by: Kiran Gunda
    Tested-by: Shawn Guo
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Now that we have a custom printf format specifier, convert users of
    full_name to use %pOF instead. This is preparation to remove storing
    of the full path string for each node.

    Signed-off-by: Rob Herring
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Rob Herring
     
  • The opc parameter in pmic_arb_write_cmd() function is defined with type
    u8 and it's always greater than or equal to 0. Checking that it's not
    less than 0 is redundant and it can cause a forbidden warning during
    compilation. Remove the check.

    Signed-off-by: Fenglin Wu
    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Fenglin Wu
     
  • Add support for version 5 of the SPMI PMIC arbiter. It utilizes
    different offsets for registers than those found on version 3.
    Also, the procedure to determine if writing and IRQ access is
    allowed for a given PPID changes for version 5.

    Signed-off-by: David Collins
    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    David Collins
     
  • If "core" memory resource is not specified, then the driver could
    end up dereferencing a null pointer. Fix this issue.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Modify the pmic_arb version ops to return an __iomem pointer
    to the address instead of an offset. That way we do not need to
    care about the base address changes in the new HW version.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Currently the driver sets the pmic arbiter core interrupt as wakeup capable
    irrespective of the child irqs which causes the system to wakeup
    unnecessarily. To fix this, set the core interrupt as wakeup capable
    only if any of the child irqs request for it. Do this by marking it as
    wakeup capable in the irq_set_wake callback.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Returning the output value from a function, when it is possible, is the
    better and cleaner way than passing it by the pointer. Hence, modify
    the ppid_to_apid mapping function to return apid instead of passing
    it by a pointer. While at it, pass the ppid as function parameter to
    ppid_to_apid mapping function instead of passing the sid and addr.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Replace the writel_relaxed with __raw_writel to avoid byte swapping
    in pmic_arb_write_data() function. That way the code is independent
    of the CPU endianness.

    Fixes: 111a10bf3e53 ("spmi: pmic-arb: rename spmi_pmic_arb_dev to
    spmi_pmic_arb")
    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Allocate the correct memory size (max_pmic_peripherals) for the
    mapping_table that holds the apid to ppid mapping. Also use a local
    variable for mapping_table for better alignment of the code.

    Fixes: 987a9f128b8a ("spmi: pmic-arb: Support more than 128 peripherals")
    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Optimize the qpnpint_irq_set_type() by using a local variable
    to hold the handler type. Also clean up other variable usage.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • Clean up the pmic_arb_find_apid() by using the local
    variables to improve the code readability.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • This patch cleans up the following.

    - Rename the "pa" to "pmic_arb".
    - Rename the spmi_pmic_arb *dev to spmi_pmic_arb *pmic_arb.
    - Rename the pa_{read,write}_data() functions to
    pmic_arb_{read,write}_data().
    - Rename channel to APID.
    - Rename the HWIRQ_*() macros to hwirq_to_*().

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • The access mode checks for peripheral ownership for read/write
    permissions should not be required. Every peripheral enabled for
    this master is expected to have a read/write permissions. If there
    is any such invalid access due to wrong configuration in boot loader
    or device tree files, then it should be fixed in those locations.
    Hence, remove the access mode checks from the driver.

    Signed-off-by: Kiran Gunda
    Reviewed-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     

17 Jul, 2017

2 commits

  • After commit 7f1d4e58dabb ("spmi: pmic-arb: optimize table
    lookups") we always need the ppid_to_apid table regardless of the
    version of pmic arbiter we have. Otherwise, we will try to deref
    the array when we don't allocate it on v2 hardware like the
    msm8974 SoCs.

    Cc: Abhijeet Dharmapurikar
    Cc: Kiran Gunda
    Fixes: 7f1d4e58dabb ("spmi: pmic-arb: optimize table lookups")
    Signed-off-by: Stephen Boyd
    Tested-by: Luca Weiss
    Reviewed-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Stephen Boyd
     
  • Include the OF-based modalias in the uevent sent when registering SPMI
    devices, so that user space has a chance to autoload the kernel module
    for the device.

    Tested-by: Rob Clark
    Reported-by: Rob Clark
    Reviewed-by: Stephen Boyd
    Signed-off-by: Bjorn Andersson
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Bjorn Andersson
     

03 Jun, 2017

11 commits

  • Currently the SPMI interrupt will not wake the device. Enable this
    interrupt as a wakeup source.

    Signed-off-by: Nicholas Troast
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Kiran Gunda
     
  • PMIC bus arbiter v3 supports 512 SPMI peripherals. Add the v3 operators to
    support this new arbiter version.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • The driver currently invokes the apid handler (periph_handler())
    once it sees that the summary status bit for that apid is set.

    However the hardware is designed to set that bit even if the apid
    interrupts are disabled. The driver should check whether the apid
    is indeed enabled before calling the apid handler.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • The current code uses handle_level_irq flow handler even if the
    trigger type of the interrupt is edge. This can lead to missing
    of an edge transition that happens when the interrupt is being
    handled. The level flow handler masks the interrupt while it is
    being handled, so if an edge transition happens at that time,
    that edge is lost.

    Use an edge flow handler for edge type interrupts which ensures
    that the interrupt stays enabled while being handled - at least
    until it triggers at which point the flow handler sets the
    IRQF_PENDING flag and only then masks the interrupt. That
    IRQF_PENDING state indicates an edge transition happened while
    the interrupt was being handled and the handler is called again.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • PMIC interrupts each have an internal latched status bit which is
    not visible from any register. This status bit is set as soon as
    the conditions specified in the interrupt type and polarity
    registers are met even if the interrupt is not enabled. When it
    is set, nothing else changes within the PMIC and no interrupt
    notification packets are sent. If the internal latched status
    bit is set when an interrupt is enabled, then the value is
    immediately propagated into the interrupt latched status register
    and an interrupt notification packet is sent out from the PMIC
    over SPMI.

    This PMIC hardware behavior can lead to a situation where the
    handler for a level triggered interrupt is called immediately
    after enable_irq() is called even though the interrupt physically
    triggered while it was disabled within the genirq framework.
    This situation takes place if the the interrupt fires twice after
    calling disable_irq(). The first time it fires, the level flow
    handler will mask and disregard it. Unfortunately, the second
    time it fires, the internal latched status bit is set within the
    PMIC and no further notification is received. When enable_irq()
    is called later, the interrupt is unmasked (enabled in the PMIC)
    which results in the PMIC immediately sending an interrupt
    notification packet out over SPMI. This breaks the semantics
    of level triggered interrupts within the genirq framework since
    they should be completely ignored while disabled.

    The PMIC internal latched status behavior also affects how
    interrupts are treated during suspend. While entering suspend,
    all interrupts not specified as wakeup mode are masked. Upon
    resume, these interrupts are unmasked. Thus if any of the
    non-wakeup PMIC interrupts fired while the system was suspended,
    then the PMIC will send interrupt notification packets out via
    SPMI as soon as they are unmasked during resume. This behavior
    violates genirq semantics as well since non-wakeup interrupts
    should be completely ignored during suspend.

    Modify the qpnpint_irq_unmask() function so that the interrupt
    latched status clear register is written immediately before the
    interrupt enable register. This clears the internal latched
    status bit of the interrupt so that it cannot trigger spuriously
    immediately upon being enabled.

    Also, while resuming an irq, an unmask could be called even if it
    was not previously masked. So, before writing these registers,
    check if the interrupt is already enabled within the PMIC. If it
    is, then no further register writes are required. This
    condition check ensures that a valid latched status register bit
    is not cleared until it is properly handled.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • irq_enable is called when the device resumes. Note that the
    irq_enable is called regardless of whether the interrupt was
    marked enabled/disabled in the descriptor or whether it was
    masked/unmasked at the controller while resuming.

    The current driver unconditionally clears the interrupt in its
    irq_enable callback. This is dangerous as any interrupts that
    happen right before the resume could be missed.
    Remove the irq_enable callback and use mask/unmask instead.

    Also remove struct pmic_arb_irq_spec as it serves no real purpose.
    It is used only in the translate function and the code is much
    cleaner without it.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • We see a unmapped irqs trigger right around bootup. This could
    likely be because the bootloader exited leaving the interrupts
    in an unknown or unhandled state. Ack and mask the interrupt
    if one is found. A request_irq later will unmask it and also
    setup proper mapping structures.

    Also the current driver ensures that no read/write transaction
    is in progress while it makes changes to the interrupt regions.
    This is not necessary because read/writes over spmi and arbiter
    interrupt control are independent operations. Hence, remove the
    synchronized accesses to interrupt region.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • The current driver uses a mix of radix tree and a fwd lookup
    table to translate between apid and ppid. It is buggy and confusing.

    Instead simply use a radix tree for v1 hardware and use the
    forward lookup table for v2.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • The driver currently uses "apid" and "chan" to mean apid. Remove
    the use of chan and use only apid.

    On a SPMI bus there is allocation to manage up to 4K peripherals.
    However, in practice only few peripherals are instantiated
    and only few among the instantiated ones actually interrupt.

    APID is CPU's way of keeping track of peripherals that could interrupt.
    There is a table that maps the 256 interrupting peripherals to
    a number between 0 and 255. This number is called APID. Information about
    that interrupting peripheral is stored in registers offset by its
    corresponding apid.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • Usually *_dev best used for structures that embed a struct device in
    them. spmi_pmic_arb_dev doesn't embed one. It is simply a driver data
    structure. Use an appropriate name for it.

    Also there are many places in the driver that left shift the bit to
    generate a bit mask. Replace it with the BIT() macro.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     
  • The system crashes due to bad access when reading from an non configured
    peripheral and when writing to peripheral which is not owned by current
    ee. This patch verifies ownership to avoid crashing on
    write.
    For reads, since the forward mapping table, data_channel->ppid, is
    towards the end of the block, we use the core size to figure the
    max number of ppids supported. The table starts at an offset of 0x800
    within the block, so size - 0x800 will give us the area used by the
    table. Since each table is 4 bytes long (core_size - 0x800) / 4 will
    gives us the number of data_channel supported.
    This new protection is functional on hw v2.

    Signed-off-by: Abhijeet Dharmapurikar
    Signed-off-by: Kiran Gunda
    Signed-off-by: Greg Kroah-Hartman

    Abhijeet Dharmapurikar
     

27 Sep, 2016

1 commit


01 May, 2016

1 commit

  • The variable p is a data structure which is used by the driver core
    internally and it is not expected that busses will be directly accessing
    these driver core internal only data.

    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Sudip Mukherjee
     

09 Feb, 2016

1 commit

  • Add support for more than 128 peripherals by taking a lazy
    caching approach to the mapping tables. Instead of reading and
    caching the tables at boot given some fixed size, read them and
    cache them on an as needed basis. We still assume a max size of
    512 peripherals, trading off some space for simplicity.

    Based on a patch by Gilad Avidov and
    Sagar Dharia .

    Cc: Gilad Avidov
    Cc: Sagar Dharia
    Signed-off-by: Stephen Boyd
    Signed-off-by: Greg Kroah-Hartman

    Stephen Boyd
     

05 Nov, 2015

1 commit

  • Pull char/misc driver updates from Greg KH:
    "Here is the big char/misc driver update for 4.4-rc1. Lots of
    different driver and subsystem updates, hwtracing being the largest
    with the addition of some new platforms that are now supported. Full
    details in the shortlog.

    All of these have been in linux-next for a long time with no reported
    issues"

    * tag 'char-misc-4.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (181 commits)
    fpga: socfpga: Fix check of return value of devm_request_irq
    lkdtm: fix ACCESS_USERSPACE test
    mcb: Destroy IDA on module unload
    mcb: Do not return zero on error path in mcb_pci_probe()
    mei: bus: set the device name before running fixup
    mei: bus: use correct lock ordering
    mei: Fix debugfs filename in error output
    char: ipmi: ipmi_ssif: Replace timeval with timespec64
    fpga: zynq-fpga: Fix issue with drvdata being overwritten.
    fpga manager: remove unnecessary null pointer checks
    fpga manager: ensure lifetime with of_fpga_mgr_get
    fpga: zynq-fpga: Change fw format to handle bin instead of bit.
    fpga: zynq-fpga: Fix unbalanced clock handling
    misc: sram: partition base address belongs to __iomem space
    coresight: etm3x: adding documentation for sysFS's cpu interface
    vme: 8-bit status/id takes 256 values, not 255
    fpga manager: Adding FPGA Manager support for Xilinx Zynq 7000
    ARM: zynq: dt: Updated devicetree for Zynq 7000 platform.
    ARM: dt: fpga: Added binding docs for Xilinx Zynq FPGA manager.
    ver_linux: proc/modules, limit text processing to 'sed'
    ...

    Linus Torvalds
     

14 Oct, 2015

1 commit

  • The struct irq_domain contains a "struct device_node *" field
    (of_node) that is almost the only link between the irqdomain
    and the device tree infrastructure.

    In order to prepare for the removal of that field, convert all
    users to use irq_domain_get_of_node() instead.

    Signed-off-by: Marc Zyngier
    Reviewed-and-tested-by: Hanjun Guo
    Tested-by: Lorenzo Pieralisi
    Cc:
    Cc: Tomasz Nowicki
    Cc: Suravee Suthikulpanit
    Cc: Graeme Gregory
    Cc: Jake Oshins
    Cc: Jiang Liu
    Cc: Jason Cooper
    Cc: Rafael J. Wysocki
    Link: http://lkml.kernel.org/r/1444737105-31573-2-git-send-email-marc.zyngier@arm.com
    Signed-off-by: Thomas Gleixner

    Marc Zyngier
     

04 Oct, 2015

2 commits

  • Silences this static checker warning:

    drivers/spmi/spmi-pmic-arb.c:363
    pmic_arb_write_cmd() warn: always true condition
    '(opc (0-255
    Signed-off-by: Stephen Boyd
    Reviewed-by: Bjorn Andersson
    Signed-off-by: Greg Kroah-Hartman

    Stephen Boyd
     
  • We don't want to swap bytes that we're reading and writing to the
    FIFOs when we're running on a big-endian CPU. Doing so causes
    problems like where the qcom-spmi-iadc driver can't detect the
    type of device because the bytes are all mixed up. Use the raw IO
    accessors for these API instead, and collapse pmic_arb_base_read()
    into the byte reading API so that we aren't tempted to read non-FIFO
    data like commands with that function.

    Cc: Andy Gross
    Signed-off-by: Stephen Boyd
    Acked-by: Bjorn Andersson
    Signed-off-by: Greg Kroah-Hartman

    Stephen Boyd
     

21 Sep, 2015

1 commit


16 Sep, 2015

1 commit

  • Most interrupt flow handlers do not use the irq argument. Those few
    which use it can retrieve the irq number from the irq descriptor.

    Remove the argument.

    Search and replace was done with coccinelle and some extra helper
    scripts around it. Thanks to Julia for her help!

    Signed-off-by: Thomas Gleixner
    Cc: Julia Lawall
    Cc: Jiang Liu

    Thomas Gleixner
     

02 Sep, 2015

1 commit

  • Pull irq updates from Thomas Gleixner:
    "This updated pull request does not contain the last few GIC related
    patches which were reported to cause a regression. There is a fix
    available, but I let it breed for a couple of days first.

    The irq departement provides:

    - new infrastructure to support non PCI based MSI interrupts
    - a couple of new irq chip drivers
    - the usual pile of fixlets and updates to irq chip drivers
    - preparatory changes for removal of the irq argument from interrupt
    flow handlers
    - preparatory changes to remove IRQF_VALID"

    * 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (129 commits)
    irqchip/imx-gpcv2: IMX GPCv2 driver for wakeup sources
    irqchip: Add bcm2836 interrupt controller for Raspberry Pi 2
    irqchip: Add documentation for the bcm2836 interrupt controller
    irqchip/bcm2835: Add support for being used as a second level controller
    irqchip/bcm2835: Refactor handle_IRQ() calls out of MAKE_HWIRQ
    PCI: xilinx: Fix typo in function name
    irqchip/gic: Ensure gic_cpu_if_up/down() programs correct GIC instance
    irqchip/gic: Only allow the primary GIC to set the CPU map
    PCI/MSI: pci-xgene-msi: Consolidate chained IRQ handler install/remove
    unicore32/irq: Prepare puv3_gpio_handler for irq argument removal
    tile/pci_gx: Prepare trio_handle_level_irq for irq argument removal
    m68k/irq: Prepare irq handlers for irq argument removal
    C6X/megamode-pic: Prepare megamod_irq_cascade for irq argument removal
    blackfin: Prepare irq handlers for irq argument removal
    arc/irq: Prepare idu_cascade_isr for irq argument removal
    sparc/irq: Use access helper irq_data_get_affinity_mask()
    sparc/irq: Use helper irq_data_get_irq_handler_data()
    parisc/irq: Use access helper irq_data_get_affinity_mask()
    mn10300/irq: Use access helper irq_data_get_affinity_mask()
    irqchip/i8259: Prepare i8259_irq_dispatch for irq argument removal
    ...

    Linus Torvalds
     

06 Aug, 2015

3 commits

  • IRQ_DOMAIN is a hidden config option, so depending on it doesn't
    make any sense. Select the config option because it's required to
    compile this driver.

    Signed-off-by: Stephen Boyd
    Reviewed-by: Andy Gross
    Signed-off-by: Greg Kroah-Hartman

    Stephen Boyd
     
  • Reviewed-by: Andy Gross
    Signed-off-by: Courtney Cavin
    Signed-off-by: Bjorn Andersson
    Tested-by: Tim Bird
    Signed-off-by: Greg Kroah-Hartman

    Courtney Cavin
     
  • Add tracepoints to retrieve information about read, write
    and non-data commands. For performance measurement support
    tracepoints are added at the beginning and at the end of
    transfers. Following is a list showing the new tracepoint
    events. The "cmd" parameter here represents the opcode, SID,
    and full 16-bit address.

    spmi_write_begin: cmd and data buffer.
    spmi_write_end : cmd and return value.
    spmi_read_begin : cmd.
    spmi_read_end : cmd, return value and data buffer.
    spmi_cmd : cmd.

    The reason that cmd appears at both the beginning and at
    the end event is that SPMI drivers can request commands
    concurrently. cmd helps in matching the corresponding
    events.

    SPMI tracepoints can be enabled like:

    echo 1 >/sys/kernel/debug/tracing/events/spmi/enable

    and will dump messages that can be viewed in
    /sys/kernel/debug/tracing/trace that look like:

    ... spmi_read_begin: opc=56 sid=00 addr=0x0000
    ... spmi_read_end: opc=56 sid=00 addr=0x0000 ret=0 len=02 buf=0x[01-40]
    ... spmi_write_begin: opc=48 sid=00 addr=0x0000 len=3 buf=0x[ff-ff-ff]

    Suggested-by: Sagar Dharia
    Acked-by: Steven Rostedt
    Reviewed-by: Stephen Boyd
    Signed-off-by: Gilad Avidov
    Signed-off-by: Ankit Gupta
    Signed-off-by: Greg Kroah-Hartman

    Ankit Gupta