12 Jan, 2020

2 commits

  • [ Upstream commit 7251953d784baf7e5416afabe030a0e81de1a938 ]

    The Freescale MPC8xxx had a special quirk for handling a
    single hardwired chipselect, the case when we're using neither
    GPIO nor native chip select: when inspecting the device tree
    and finding zero "cs-gpios" on the device node the code would
    assume we have a single hardwired chipselect that leaves the
    device always selected.

    This quirk is not handled by the new core code, so we need
    to check the "cs-gpios" explicitly in the driver and set
    pdata->max_chipselect = 1 which will later fall through to
    the SPI master ->num_chipselect.

    Make sure not to assign the chip select handler in this
    case: there is no handling needed since the chip is always
    selected, and this is what the old code did as well.

    Cc: Christophe Leroy
    Reported-by: Christophe Leroy
    Fixes: 0f0581b24bd0 ("spi: fsl: Convert to use CS GPIO descriptors")
    Signed-off-by: Linus Walleij
    Tested-by: Christophe Leroy (No tested the
    Link: https://lore.kernel.org/r/20191128083718.39177-3-linus.walleij@linaro.org
    Signed-off-by: Mark Brown
    Signed-off-by: Sasha Levin

    Linus Walleij
     
  • [ Upstream commit f106904968e2a075e64653b9b79dda9f0f070ab5 ]

    This makes the driver actually support looking up GPIO
    descriptor. A coding mistake in the initial descriptor
    support patch was that it was failing to turn on the very
    feature it was implementing. Mea culpa.

    Cc: Christophe Leroy
    Reported-by: Christophe Leroy
    Fixes: 0f0581b24bd0 ("spi: fsl: Convert to use CS GPIO descriptors")
    Signed-off-by: Linus Walleij
    Tested-by: Christophe Leroy
    Link: https://lore.kernel.org/r/20191128083718.39177-1-linus.walleij@linaro.org
    Signed-off-by: Mark Brown
    Signed-off-by: Sasha Levin

    Linus Walleij
     

31 Dec, 2019

2 commits

  • commit 63aa6a692595d47a0785297b481072086b9272d2 upstream.

    Unlike irq_of_parse_and_map() which has a dummy definition on SPARC,
    of_irq_to_resource() hasn't.

    But as platform_get_irq() can be used instead and is generic, use it.

    Reported-by: kbuild test robot
    Suggested-by: Mark Brown
    Fixes: 3194d2533eff ("spi: fsl: don't map irq during probe")
    Cc: stable@vger.kernel.org
    Signed-off-by: Christophe Leroy
    Link: https://lore.kernel.org/r/091a277fd0b3356dca1e29858c1c96983fc9cb25.1576172743.git.christophe.leroy@c-s.fr
    Signed-off-by: Mark Brown
    Signed-off-by: Greg Kroah-Hartman

    Christophe Leroy
     
  • commit 3194d2533efffae8b815d84729ecc58b6a9000ab upstream.

    With lastest kernel, the following warning is observed at startup:

    [ 1.500609] ------------[ cut here ]------------
    [ 1.505225] remove_proc_entry: removing non-empty directory 'irq/22', leaking at least 'fsl_spi'
    [ 1.514234] WARNING: CPU: 0 PID: 1 at fs/proc/generic.c:682 remove_proc_entry+0x198/0x1c0
    [ 1.522403] CPU: 0 PID: 1 Comm: swapper Not tainted 5.4.0-s3k-dev-02248-g93532430a4ff #2564
    [ 1.530724] NIP: c0197694 LR: c0197694 CTR: c0050d80
    [ 1.535762] REGS: df4a5af0 TRAP: 0700 Not tainted (5.4.0-02248-g93532430a4ff)
    [ 1.543818] MSR: 00029032 CR: 22028222 XER: 00000000
    [ 1.550524]
    [ 1.550524] GPR00: c0197694 df4a5ba8 df4a0000 00000054 00000000 00000000 00004a38 00000010
    [ 1.550524] GPR08: c07c5a30 00000800 00000000 00001032 22000208 00000000 c0004b14 00000000
    [ 1.550524] GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 c0830000 c07fc078
    [ 1.550524] GPR24: c08e8ca0 df665d10 df60ea98 c07c9db8 00000001 df5d5ae3 df5d5a80 df43f8e3
    [ 1.585327] NIP [c0197694] remove_proc_entry+0x198/0x1c0
    [ 1.590628] LR [c0197694] remove_proc_entry+0x198/0x1c0
    [ 1.595829] Call Trace:
    [ 1.598280] [df4a5ba8] [c0197694] remove_proc_entry+0x198/0x1c0 (unreliable)
    [ 1.605321] [df4a5bd8] [c0067acc] unregister_irq_proc+0x5c/0x70
    [ 1.611238] [df4a5bf8] [c005fbc4] free_desc+0x3c/0x80
    [ 1.616286] [df4a5c18] [c005fe2c] irq_free_descs+0x70/0xa8
    [ 1.621778] [df4a5c38] [c033d3fc] of_fsl_spi_probe+0xdc/0x3cc
    [ 1.627525] [df4a5c88] [c02f0f64] platform_drv_probe+0x44/0xa4
    [ 1.633350] [df4a5c98] [c02eee44] really_probe+0x1ac/0x418
    [ 1.638829] [df4a5cc8] [c02ed3e8] bus_for_each_drv+0x64/0xb0
    [ 1.644481] [df4a5cf8] [c02ef950] __device_attach+0xd4/0x128
    [ 1.650132] [df4a5d28] [c02ed61c] bus_probe_device+0xa0/0xbc
    [ 1.655783] [df4a5d48] [c02ebbe8] device_add+0x544/0x74c
    [ 1.661096] [df4a5d88] [c0382b78] of_platform_device_create_pdata+0xa4/0x100
    [ 1.668131] [df4a5da8] [c0382cf4] of_platform_bus_create+0x120/0x20c
    [ 1.674474] [df4a5df8] [c0382d50] of_platform_bus_create+0x17c/0x20c
    [ 1.680818] [df4a5e48] [c0382e88] of_platform_bus_probe+0x9c/0xf0
    [ 1.686907] [df4a5e68] [c0751404] __machine_initcall_cmpcpro_cmpcpro_declare_of_platform_devices+0x74/0x1a4
    [ 1.696629] [df4a5e98] [c072a4cc] do_one_initcall+0x8c/0x1d4
    [ 1.702282] [df4a5ef8] [c072a768] kernel_init_freeable+0x154/0x204
    [ 1.708455] [df4a5f28] [c0004b2c] kernel_init+0x18/0x110
    [ 1.713769] [df4a5f38] [c00122ac] ret_from_kernel_thread+0x14/0x1c
    [ 1.719926] Instruction dump:
    [ 1.722889] 2c030000 4182004c 3863ffb0 3c80c05f 80e3005c 388436a0 3c60c06d 7fa6eb78
    [ 1.730630] 7fe5fb78 38840280 38634178 4be8c611 4bffff6c 3c60c071 7fe4fb78
    [ 1.738556] ---[ end trace 05d0720bf2e352e2 ]---

    The problem comes from the error path which calls
    irq_dispose_mapping() while the IRQ has been requested with
    devm_request_irq().

    IRQ doesn't need to be mapped with irq_of_parse_and_map(). The only
    need is to get the IRQ virtual number. For that, use
    of_irq_to_resource() instead of the
    irq_of_parse_and_map()/irq_dispose_mapping() pair.

    Fixes: 500a32abaf81 ("spi: fsl: Call irq_dispose_mapping in err path")
    Cc: stable@vger.kernel.org
    Signed-off-by: Christophe Leroy
    Link: https://lore.kernel.org/r/518cfb83347d5372748e7fe72f94e2e9443d0d4a.1575905123.git.christophe.leroy@c-s.fr
    Signed-off-by: Mark Brown
    Signed-off-by: Greg Kroah-Hartman

    Christophe Leroy
     

28 Aug, 2019

1 commit

  • This converts the Freescale SPI master driver to use GPIO
    descriptors for chip select handling.

    The Freescale (fsl) driver has a lot of quirks to look up
    "gpios" rather than "cs-gpios" from the device tree.
    After the prior patch that will make gpiolib return the
    GPIO descriptor for "gpios" in response to a request for
    "cs-gpios", this code can be cut down quite a bit.

    The driver has custom handling of chip select rather
    than using the core (which may be possible but not
    done in this patch) so it still needs to refer directly
    to spi->cs_gpiod to set the chip select.

    Cc: Shawn Guo
    Cc: Sascha Hauer
    Cc: Pengutronix Kernel Team
    Cc: Fabio Estevam
    Cc: NXP Linux Team
    Signed-off-by: Linus Walleij
    Link: https://lore.kernel.org/r/20190804003539.985-1-linus.walleij@linaro.org
    Signed-off-by: Mark Brown

    Linus Walleij
     

11 Jun, 2019

1 commit

  • Pull spi fixes from Mark Brown:
    "A small set of fixes here.

    One core fix for error handling when we fail to set up the hardware
    before initiating a transfer and another one reverting a change in the
    core which broke Raspberry Pi in common use cases as part of some
    optimization work.

    There's also a couple of driver specific fixes"

    * tag 'spi-fix-v5.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
    spi: abort spi_sync if failed to prepare_transfer_hardware
    spi: spi-fsl-spi: call spi_finalize_current_message() at the end
    spi: bitbang: Fix NULL pointer dereference in spi_unregister_master
    spi: Fix Raspberry Pi breakage

    Linus Torvalds
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

22 May, 2019

1 commit


02 Apr, 2019

2 commits

  • Taking one interrupt for every byte is rather slow. Since the
    controller is perfectly capable of transmitting 32 bits at a time,
    change t->bits_per-word to 32 when the length is divisible by 4 and
    large enough that the reduced number of interrupts easily compensates
    for the one or two extra fsl_spi_setup_transfer() calls this causes.

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Mark Brown

    Rasmus Villemoes
     
  • Commit c9bfcb315104 (spi_mpc83xx: much improved driver) introduced
    logic to ensure bits_per_word and speed_hz stay the same for a series
    of spi_transfers with CS active, arguing that

    The current driver may cause glitches on SPI CLK line since one
    must disable the SPI controller before changing any HW settings.

    This sounds quite reasonable. So this is a quite naive attempt at
    relaxing this sanity checking to only ensure that speed_hz is
    constant - in the faint hope that if we do not causes changes to the
    clock-related fields of the SPMODE register (DIV16 and PM), those
    glitches won't appear.

    The purpose of this change is to allow automatically optimizing large
    transfers to use 32 bits-per-word; taking one interrupt for every byte
    is extremely slow.

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Mark Brown

    Rasmus Villemoes
     

01 Apr, 2019

2 commits


18 Mar, 2019

1 commit

  • The MPC8309 has a dedicated signal, SPISEL_BOOT, usually used as chip
    select for the flash device from which the bootloader is loaded. It is
    not an ordinary gpio, but is simply controlled via the SPI_CS register
    in the system configuration.

    To allow accessing such a spi slave, we need to teach
    fsl_spi_cs_control() how to control the SPISEL_BOOT signal. To
    distinguish the gpio-controlled slaves, continue to have those use
    chip_select values of 0..ngpios-1, and use chip_select == ngpios for
    the boot flash.

    I'm not too happy with all the ifdeffery, but it seems to be necessary
    for guarding the sysdev/fsl_soc.h and use of
    get_immrbase() (spi-fsl-lib.c already contains similar ifdeffery).

    Googling suggests that the MPC8306 is similar, with the SPI_CS
    register at the same offset.

    Signed-off-by: Rasmus Villemoes
    Signed-off-by: Mark Brown

    Rasmus Villemoes
     

26 Apr, 2017

1 commit


14 Mar, 2017

1 commit


18 Jan, 2017

3 commits


30 Aug, 2015

1 commit


29 Aug, 2015

2 commits


15 Dec, 2014

1 commit

  • Pull driver core update from Greg KH:
    "Here's the set of driver core patches for 3.19-rc1.

    They are dominated by the removal of the .owner field in platform
    drivers. They touch a lot of files, but they are "simple" changes,
    just removing a line in a structure.

    Other than that, a few minor driver core and debugfs changes. There
    are some ath9k patches coming in through this tree that have been
    acked by the wireless maintainers as they relied on the debugfs
    changes.

    Everything has been in linux-next for a while"

    * tag 'driver-core-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (324 commits)
    Revert "ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries"
    fs: debugfs: add forward declaration for struct device type
    firmware class: Deletion of an unnecessary check before the function call "vunmap"
    firmware loader: fix hung task warning dump
    devcoredump: provide a one-way disable function
    device: Add dev__once variants
    ath: ath9k: use debugfs_create_devm_seqfile() helper for seq_file entries
    ath: use seq_file api for ath9k debugfs files
    debugfs: add helper function to create device related seq_file
    drivers/base: cacheinfo: remove noisy error boot message
    Revert "core: platform: add warning if driver has no owner"
    drivers: base: support cpu cache information interface to userspace via sysfs
    drivers: base: add cpu_device_create to support per-cpu devices
    topology: replace custom attribute macros with standard DEVICE_ATTR*
    cpumask: factor out show_cpumap into separate helper function
    driver core: Fix unbalanced device reference in drivers_probe
    driver core: fix race with userland in device_add()
    sysfs/kernfs: make read requests on pre-alloc files use the buffer.
    sysfs/kernfs: allow attributes to request write buffer be pre-allocated.
    fs: sysfs: return EGBIG on write if offset is larger than file size
    ...

    Linus Torvalds
     

05 Dec, 2014

2 commits


03 Dec, 2014

1 commit


20 Oct, 2014

1 commit


03 Oct, 2014

1 commit


30 Sep, 2014

1 commit

  • Sort all the include headers alphabetically for the freescale
    spi drivers. If the inlcude headers sorted out of order, maybe
    the best logical choice is to append new ones after the exist
    ones, while this may create a lot of potential for duplicates
    and conflicts for each diffenent changes will add new headers
    in the same location.

    Signed-off-by: Xiubo Li
    Signed-off-by: Mark Brown

    Xiubo Li
     

01 Sep, 2014

1 commit

  • device_add() expects that any memory allocated via devm_* API is only
    done in the device's probe function.

    Fix below boot warning:
    [ 3.092348] WARNING: at drivers/base/dd.c:286
    [ 3.096637] Modules linked in:
    [ 3.099697] CPU: 0 PID: 25 Comm: kworker/u2:1 Tainted: G W 3.16.1-s3k-drv-999-svn5771_knld-999 #158
    [ 3.109610] Workqueue: deferwq deferred_probe_work_func
    [ 3.114736] task: c787f020 ti: c790c000 task.ti: c790c000
    [ 3.120062] NIP: c01df158 LR: c01df144 CTR: 00000000
    [ 3.124983] REGS: c790db30 TRAP: 0700 Tainted: G W (3.16.1-s3k-drv-999-svn5771_knld-999)
    [ 3.134162] MSR: 00029032 CR: 22002082 XER: 20000000
    [ 3.140703]
    [ 3.140703] GPR00: 00000001 c790dbe0 c787f020 00000044 00000054 00000308 c056da0e 20737069
    [ 3.140703] GPR08: 33323736 000ebfe0 00000308 000ebfdf 22002082 00000000 c046c5a0 c046c608
    [ 3.140703] GPR16: c046c614 c046c620 c046c62c c046c638 c046c648 c046c654 c046c68c c046c6c4
    [ 3.140703] GPR24: 00000000 00000000 00000003 c0401aa0 c0596638 c059662c c054e7a8 c7996800
    [ 3.170102] NIP [c01df158] driver_probe_device+0xf8/0x334
    [ 3.175431] LR [c01df144] driver_probe_device+0xe4/0x334
    [ 3.180633] Call Trace:
    [ 3.183093] [c790dbe0] [c01df144] driver_probe_device+0xe4/0x334 (unreliable)
    [ 3.190147] [c790dc10] [c01dd15c] bus_for_each_drv+0x7c/0xc0
    [ 3.195741] [c790dc40] [c01df5fc] device_attach+0xcc/0xf8
    [ 3.201076] [c790dc60] [c01dd6d4] bus_probe_device+0xb4/0xc4
    [ 3.206666] [c790dc80] [c01db9f8] device_add+0x270/0x564
    [ 3.211923] [c790dcc0] [c0219e84] spi_add_device+0xc0/0x190
    [ 3.217427] [c790dce0] [c021a79c] spi_register_master+0x720/0x834
    [ 3.223455] [c790dd40] [c021cb48] of_fsl_spi_probe+0x55c/0x614
    [ 3.229234] [c790dda0] [c01e0d2c] platform_drv_probe+0x30/0x74
    [ 3.234987] [c790ddb0] [c01df18c] driver_probe_device+0x12c/0x334
    [ 3.241008] [c790dde0] [c01dd15c] bus_for_each_drv+0x7c/0xc0
    [ 3.246602] [c790de10] [c01df5fc] device_attach+0xcc/0xf8
    [ 3.251937] [c790de30] [c01dd6d4] bus_probe_device+0xb4/0xc4
    [ 3.257536] [c790de50] [c01de9d8] deferred_probe_work_func+0x98/0xe0
    [ 3.263816] [c790de70] [c00305b8] process_one_work+0x18c/0x440
    [ 3.269577] [c790dea0] [c0030a00] worker_thread+0x194/0x67c
    [ 3.275105] [c790def0] [c0039198] kthread+0xd0/0xe4
    [ 3.279911] [c790df40] [c000c6d0] ret_from_kernel_thread+0x5c/0x64
    [ 3.285970] Instruction dump:
    [ 3.288900] 80de0000 419e01d0 3b7b0038 3c60c046 7f65db78 38635264 48211b99 813f00a0
    [ 3.296559] 381f00a0 7d290278 3169ffff 7c0b4910 93df0044 7fe3fb78 4bfffd4d

    Reported-by: leroy christophe
    Signed-off-by: Axel Lin
    Tested-by: Christophe Leroy
    Signed-off-by: Mark Brown
    Cc: stable@vger.kernel.org

    Axel Lin
     

06 Jun, 2014

1 commit


15 Apr, 2014

1 commit

  • mpc8xxx_spi_probe() has set master->cleanup = mpc8xxx_spi_cleanup,
    however current code overrides the setting in fsl_spi_probe() and set
    master->cleanup = fsl_spi_cleanup.
    Thus the memory allocated for cs is not freed anywhere.
    Convert to use devm_kzalloc to fix the memory leak.

    Signed-off-by: Axel Lin
    Signed-off-by: Mark Brown

    Axel Lin
     

11 Apr, 2014

1 commit


03 Apr, 2014

1 commit


23 Feb, 2014

1 commit


04 Feb, 2014

1 commit

  • When used via spidev with more than one messages to tranfer via
    SPI_IOC_MESSAGE the current implementation would return with
    -EINVAL, since bits_per_word and speed_hz are set in all
    transfer structs. And in the 2nd loop status will stay at
    -EINVAL as its not overwritten again via fsl_spi_setup_transfer().

    This patch changes this behavious by first checking if one of
    the messages uses different settings. If this is the case
    the function will return with -EINVAL. If not, the messages
    are transferred correctly.

    Signed-off-by: Stefan Roese
    Signed-off-by: Mark Brown

    Stefan Roese
     

15 Nov, 2013

1 commit


05 Sep, 2013

1 commit

  • Pull PTR_RET() removal patches from Rusty Russell:
    "PTR_RET() is a weird name, and led to some confusing usage. We ended
    up with PTR_ERR_OR_ZERO(), and replacing or fixing all the usages.

    This has been sitting in linux-next for a whole cycle"

    [ There are still some PTR_RET users scattered about, with some of them
    possibly being new, but most of them existing in Rusty's tree too. We
    have that

    #define PTR_RET(p) PTR_ERR_OR_ZERO(p)

    thing in , so they continue to work for now - Linus ]

    * tag 'PTR_RET-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    GFS2: Replace PTR_RET with PTR_ERR_OR_ZERO
    Btrfs: volume: Replace PTR_RET with PTR_ERR_OR_ZERO
    drm/cma: Replace PTR_RET with PTR_ERR_OR_ZERO
    sh_veu: Replace PTR_RET with PTR_ERR_OR_ZERO
    dma-buf: Replace PTR_RET with PTR_ERR_OR_ZERO
    drivers/rtc: Replace PTR_RET with PTR_ERR_OR_ZERO
    mm/oom_kill: remove weird use of ERR_PTR()/PTR_ERR().
    staging/zcache: don't use PTR_RET().
    remoteproc: don't use PTR_RET().
    pinctrl: don't use PTR_RET().
    acpi: Replace weird use of PTR_RET.
    s390: Replace weird use of PTR_RET.
    PTR_RET is now PTR_ERR_OR_ZERO(): Replace most.
    PTR_RET is now PTR_ERR_OR_ZERO

    Linus Torvalds
     

29 Aug, 2013

1 commit


15 Jul, 2013

1 commit


23 May, 2013

1 commit

  • Use the wrapper functions for getting and setting the driver data using
    platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
    so we can directly pass a struct platform_device.

    Signed-off-by: Jingoo Han
    Signed-off-by: Mark Brown

    Jingoo Han