aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libahci_platform.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-01-11ata: libahci_platform: comply to PHY frameworkMiquel Raynal1-0/+13
Current implementation of the libahci does not take into account the new PHY framework. Correct the situation by adding a call to phy_set_mode() before phy_power_on(). PHYs should also be handled at suspend/resume time. For this, call ahci_platform_enable/disable_phys() at suspend/resume_host() time. These calls are guarded by a HFLAG (AHCI_HFLAG_SUSPEND_PHYS) that the user of the libahci driver must set manually in hpriv->flags at probe time. This is to avoid breaking users that have not been tested with this change. Reviewed-by: Hans de Goede <hdegoede@redhat.com> Suggested-by: Grzegorz Jaszczyk <jaz@semihalf.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-09-03ata: ahci_platform: add support for PHY controller regulatorCorentin Labbe1-0/+20
The SoC R40 AHCI controller need a PHY regulator to work. But since the PHY is embedded in the controller, we cannot do a DT node for it, since phy-supply works only in node with a PHY compatible. So this patch adds a way to add an optional phy-supply regulator on AHCI controller node. Acked-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-09-03ata: ahci_platform: add support for AHCI controller regulatorCorentin Labbe1-2/+24
The SoC R40 AHCI controller need a regulator to work. So this patch add a way to add an optional regulator on AHCI controller. Acked-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-08-28ata: ahci: Convert to using %pOFn instead of device_node.nameRob Herring1-4/+4
In preparation to remove the node name pointer from struct device_node, convert printf users to use the %pOFn format specifier. Cc: Hans de Goede <hdegoede@redhat.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: linux-ide@vger.kernel.org Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
2018-08-22ata: libahci_platform: add reset control supportKunihiko Hayashi1-5/+26
Add support to get and control a list of resets for the device as optional and shared. These resets must be kept de-asserted until the device is enabled. This is specified as shared because some SoCs like UniPhier series have common reset controls with all ahci controller instances. However, according to Thierry's view, https://www.spinics.net/lists/linux-ide/msg55357.html some hardware-specific drivers already use their own resets, and the common reset make a path to occur double controls of resets. The ahci_platform_get_resources() can get and control the reset only when the second argument includes AHCI_PLATFORM_GET_RESETS bit. Suggested-by: Hans de Goede <hdegoede@redhat.com> Cc: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2018-08-22ata: add an extra argument to ahci_platform_get_resources()Kunihiko Hayashi1-1/+3
Add an extra argument to ahci_platform_get_resources(), that is for the bitmap representing the resource to get in this function. Currently there is no resources to be defined, so all the callers set '0' to the argument. Suggested-by: Hans de Goede <hdegoede@redhat.com> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: Patrice Chotard <patrice.chotard@st.com> Cc: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2018-08-06Revert "ata: ahci_platform: allow disabling of hotplug to save power"Tejun Heo1-65/+17
This reverts commit aece27a2f01be4bb7683790f69cd1bed3a0929a2. Causes boot failure on some devices. http://lore.kernel.org/r/CA+G9fYuKW_jCFZPqG4tz=QY9ROfHO38KiCp9XTA+KaDOFVtcqQ@mail.gmail.com Signed-off-by: Tejun Heo <tj@kernel.org>
2018-07-24Revert "ata: ahci_platform: convert kcalloc to devm_kcalloc"Corentin Labbe1-1/+7
Since ahci_platform_put_resources() use target_pwrs after "devm_" freed it, we cannot use devm_kcalloc for allocating target_pwrs. This reverts commit bd0038b1b4f499d814d8f33a55b1df5ea6cf3b85. Reported-and-reviwed-by: Mikko Perttunen <mperttunen@nvidia.com> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2018-07-12ata: ahci_platform: convert kcalloc to devm_kcallocCorentin Labbe1-3/+1
Like phys, target_pwrs could be allocated with devm_ function Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2018-07-12ata: ahci_platform: convert kzallloc to kcallocCorentin Labbe1-5/+3
It's better to kcalloc instead of kzalloc(n * sizeof()) Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2018-07-12ata: ahci_platform: correct parameter documentation for ahci_platform_shutdownCorentin Labbe1-1/+1
The documentation about parameter for ahci_platform_shutdown has a typo. This fix the following build warning: drivers/ata/libahci_platform.c:693: warning: Function parameter or member 'pdev' not described in 'ahci_platform_shutdown' drivers/ata/libahci_platform.c:693: warning: Excess function parameter 'dev' description in 'ahci_platform_shutdow Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2018-06-18ata: ahci_platform: allow disabling of hotplug to save powerSamuel Morris1-17/+65
A number of resources remain powered to support hotplug. On platforms I've worked with, allowing the ahci_platform to suspend saves about 150mW. This patch enables rpm and allows the device to be auto-suspended through sysfs. Signed-off-by: Samuel Morris <samorris@lexmark.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2018-04-09Revert "ata: ahci-platform: add reset control support"Kunihiko Hayashi1-21/+3
This reverts commit f0f56716fc3e5d547fd7811eb218a30ed0695605. According to Thierry's view, https://www.spinics.net/lists/linux-ide/msg55357.html some hardware-specific drivers already use their own resets, and the common reset might make a path to occur double controls of resets. For now, revert the commit that adds reset control support to ahci-platform, and hold until the solution is confirmed not be affect all hardware-specific drivers. Fixes: f0f56716fc3e ("ata: ahci-platform: add reset control support") Reported-by: Thierry Reding <thierry.reding@gmail.com> Suggested-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2018-03-26ata: ahci-platform: add reset control supportKunihiko Hayashi1-3/+21
Add support to get and control a list of resets for the device as optional and shared. These resets must be kept de-asserted until the device is enabled. This is specified as shared because some SoCs like UniPhier series have common reset controls with all ahci controller instances. Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2018-02-12ata: libahci: fix comment indentationBaruch Siach1-1/+1
Indent the numbered item with one space like all other items in the same list. Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Tejun Heo <tj@kernel.org>
2017-10-23ata: mark expected switch fall-throughsGustavo A. R. Silva1-0/+1
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. In cases where a "drop through" comment was already in place, I replaced it with a proper "fall through" comment, which is what GCC is expecting to find. Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2017-08-04ata: ahci_platform: Add shutdown handlerNate Watterson1-0/+34
The newly introduced ahci_platform_shutdown() method is called during system shutdown to disable host controller DMA and interrupts in order to avoid potentially corrupting or otherwise interfering with a new kernel being started with kexec. Signed-off-by: Nate Watterson <nwatters@codeaurora.org> Signed-off-by: Tejun Heo <tj@kernel.org>
2017-05-16ata: libahci: properly propagate return value of platform_get_irq()Thomas Petazzoni1-2/+3
When platform_get_irq() fails, it returns an error code, which libahci_platform and replaces it by -EINVAL. This commit fixes that by propagating the error code. It fixes the situation where platform_get_irq() returns -EPROBE_DEFER because the interrupt controller is not available yet, and generally looks like the right thing to do. We pay attention to not show the "no irq" message when we are in an EPROBE_DEFER situation, because the driver probing will be retried later on, once the interrupt controller becomes available to provide the interrupt. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2015-06-03ahci: Store irq number in struct ahci_host_privRobert Richter1-1/+3
Currently, ahci supports only msi and intx. To also support msix the handling of the irq number need to be changed. The irq number for msix devices is taken from msi_list instead of pci_dev. Thus, the irq number of a device needs to be stored in struct ahci_host_priv now. This allows the host controller to be activated in a generic way. This change is only intended for ahci drivers. For that reason the irq number is stored in struct ahci_host_priv used only by ahci drivers. Thus, the ABI changes only for ahci_host_activate(), but existing ata drivers (about 50) are unaffected and keep unchanged. All users of ahci_host_activate() have been updated. While touching drivers/ata/libahci.c, doing a small code cleanup in ahci_port_start(). Signed-off-by: Robert Richter <rrichter@cavium.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2015-02-03ata: libahci: Use of_platform_device_create only if supportedGuenter Roeck1-1/+3
of_platform_device_create does not exist if OF_ADDRESS is not configured, so limit its use accordingly. Without this fix, the sparc64:allmodconfig build fails with ERROR: "of_platform_device_create" [drivers/ata/libahci_platform.ko] undefined! Fixes: c7d7ddee7e24 ("ata: libahci: Allow using multiple regulators") Cc: Gregory CLEMENT <gregory.clement@free-electrons.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Tejun Heo <tj@kernel.org>
2015-01-28ata: ahci_platform: fix owner module reference mismatch for scsi hostAkinobu Mita1-6/+4
The owner module reference of the ahci platform's scsi_host is initialized to libahci_platform's one, because these drivers use a scsi_host_template defined in libahci_platform. So these drivers can be unloaded even if the scsi device is being accessed. This fixes it by pushing the scsi_host_template from libahci_platform to all leaf drivers. The scsi_host_template is passed through a new argument of ahci_platform_init_host(). Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: "James E.J. Bottomley" <JBottomley@parallels.com> Cc: linux-ide@vger.kernel.org Cc: linux-scsi@vger.kernel.org
2015-01-21ata: libahci: Fix devres cleanup on failureThierry Reding1-1/+2
Commit c7d7ddee7e24 ("ata: libahci: Allow using multiple regulators") releases regulators during ahci_platform_put_resources(). That doesn't work because the function is run as part of the devres machinery. Such resources are torn down in reverse order. Since the array that holds pointers to the regulators is allocated using devres after the device context to which ahci_platform_put_resources() is attached, the memory will be freed before calling ahci_platform_put_resources() and thereby causing a use-after-free error. This commit fixes this by using regular allocations for the array. The memory can then be freed after the regulators have been released. This conserves the advantages of using the managed API. Reported-by: Paul Walmsley <paul@pwsan.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2015-01-19ata: libahci: Allow using multiple regulatorsGregory CLEMENT1-65/+165
The current implementation of the libahci allows using multiple PHYs but not multiple regulators. This patch adds the support of multiple regulators. Until now it was mandatory to have a PHY under a subnode, now a port subnode can contain either a regulator or a PHY (or both). In order to be able to asociate a port with a regulator the port are now a platform device in the device tree case. There was only one driver which used directly the regulator field of the ahci_host_priv structure. To preserve the bisectability the change in the ahci_imx driver was done in the same patch. Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2015-01-19ata: libahci: Clean-up the ahci_platform_en/disable_phys functionsGregory CLEMENT1-6/+0
The phy_ functions handle the NULL pointer case, so there is no need to skip them if there is a NULL pointer. Moreover, after the error label there is already no check on the pointer. This patch removes the unnecessary tests and brings some consistency. Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2014-10-06AHCI: Move host activation code into ahci_host_activate()Alexander Gordeev1-2/+1
Currently host activation done by calling either function ahci_host_activate() or ata_host_activate(). Consolidate the code by only calling ahci_host_activate() for all AHCI devices. Signed-off-by: Alexander Gordeev <agordeev@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org> Cc: linux-ide@vger.kernel.org
2014-08-30libahci_platform: Staticize ahci_platform_<en/dis>able_phys()Fabio Estevam1-4/+2
ahci_platform_enable_phys() and ahci_platform_disable_phys() are currently exported, but they are not used anywhere else other than libahci_platform.c. So make them static and do not export them to fix the following sparse warnings: drivers/ata/libahci_platform.c:52:5: warning: symbol 'ahci_platform_enable_phys' was not declared. Should it be static? drivers/ata/libahci_platform.c:88:6: warning: symbol 'ahci_platform_disable_phys' was not declared. Should it be static? Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2014-08-16ata: remove deprecated struct ahci_platform_dataBartlomiej Zolnierkiewicz1-23/+0
The last user of the deprecated struct ahci_platform_data has been cleaned up recently (SPEAr1340 got a proper PHY driver). Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2014-08-01ata: libahci: Silence compiler warning on 64-bitThierry Reding1-1/+1
Commit 725c7b570fda (ata: libahci_platform: move port_map parameters into the AHCI structure) moves flags into the struct ahci_host_priv's .flags field, which causes compiler warnings on 64-bit builds when that value is cast to a void * pointer. Cast to an unsigned long so that the subsequent cast to a pointer doesn't produce a warning. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2014-07-30ata: libahci: allow to use multiple PHYsAntoine Ténart1-38/+151
The current implementation of the libahci does not allow to use multiple PHYs. This patch adds the support of multiple PHYs by the libahci while keeping the old bindings valid for device tree compatibility. This introduce a new way of defining SATA ports in the device tree, with one port per sub-node. This as the advantage of allowing a per port configuration. Because some ports may be accessible but disabled in the device tree, the port_map mask is computed automatically when using this. Signed-off-by: Antoine Ténart <antoine.tenart@free-electrons.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2014-07-30ata: libahci_platform: move port_map parameters into the AHCI structureAntoine Ténart1-10/+3
This patch moves force_port_map and mask_port_map into the ahci_host_priv structure. This allows to modify them into the AHCI framework. This is needed by the new dt bindings representing ports as the port_map mask is computed automatically. Parameters modifying force_port_map, mask_port_map and flags have been removed from the ahci_platform_init_host() function, and inputs in the ahci_host_priv structure are now directly filed. Signed-off-by: Antoine Ténart <antoine.tenart@free-electrons.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2014-07-30Merge branch 'for-3.16-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata into for-3.17Tejun Heo1-1/+6
The scheduled ahci platform patches depend on change in for-3.16-fixes. Pull it into for-3.17. Signed-off-by: Tejun Heo <tj@kernel.org>
2014-06-17ahci: Check and set 64-bit DMA mask for platform AHCI driverSuravee Suthikulpanit1-0/+13
The current platform AHCI driver does not set the dma_mask correctly for 64-bit DMA capable AHCI controller. This patch checks the AHCI capability bit and set the dma_mask and coherent_dma_mask accordingly. Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Tested-by: Suman Tripathi <stripathi@apm.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2014-06-17libahci_platform: Fail when PHY required but PHY support disabledMikko Perttunen1-1/+6
ahci_platform_get_resources handles resource management for platform AHCI drivers, including getting a possible PHY from the device tree. Since not all drivers need a PHY, it ignores -ENODEV and -ENOSYS from devm_get_phy. However, when the PHY subsystem is mistakenly disabled, -ENOSYS can be returned even when a PHY is needed. This patch modifies the -ENOSYS case to check if a "phys" device tree node exists. If it exists, then clearly the PHY subsystem is mistakenly disabled and the driver cannot work, ahci_platform_get_resources will fail and propagate the error. Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com> Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Tejun Heo <tj@kernel.org>
2014-05-14libahci_platform: add host_flags parameter in ahci_platform_init_host()Kefeng Wang1-1/+4
Add a dynamic host_flags argument to make ahci_platform_init_host more flexible, then remove the AHCI_HFLAGS(...) argument from some driver's ata_port_info, and pass that in as the new argument. Cc: Hans de Geode <hdegoede@redhat.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Kefeng Wang <kefeng.wang@linaro.org> Signed-off-by: Tejun Heo <tj@kernel.org>
2014-03-25ata: move library code from ahci_platform.c to libahci_platform.cBartlomiej Zolnierkiewicz1-0/+541
Move AHCI platform library code from ahci_platform.c to libahci_platform.c and fix dependencies for ahci_st, ahci_imx and ahci_sunxi drivers. Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Tejun Heo <tj@kernel.org>