aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2014-03-20 05:20:46 -0400
committerBrian Norris <computersforpeace@gmail.com>2014-03-20 07:17:17 -0400
commita63984c18a6186a323987817f01095d07503bda1 (patch)
treeda4a0da3d013be82943b04b5159b39fc94071489 /drivers/mtd
parente209e1e8e330b55feaa16ed62836e3665026e406 (diff)
mtd: st_spi_fsm: Fetch boot-device from mode pins
It's important for us to determine which device was used to boot from in order to make some correct decisions surrounding Power Management. On each of the platforms which support the FSM this is communicated via a set of mode pins held in the system configuration area. This patch determine the boot device and stores the result. Acked-by Angus Clark <angus.clark@st.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/devices/st_spi_fsm.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
index 83cf9dfd02e7..6be267277756 100644
--- a/drivers/mtd/devices/st_spi_fsm.c
+++ b/drivers/mtd/devices/st_spi_fsm.c
@@ -14,7 +14,9 @@
14 */ 14 */
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/regmap.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/mfd/syscon.h>
18#include <linux/mtd/mtd.h> 20#include <linux/mtd/mtd.h>
19#include <linux/sched.h> 21#include <linux/sched.h>
20#include <linux/delay.h> 22#include <linux/delay.h>
@@ -207,6 +209,7 @@ struct stfsm {
207 struct flash_info *info; 209 struct flash_info *info;
208 210
209 uint32_t fifo_dir_delay; 211 uint32_t fifo_dir_delay;
212 bool booted_from_spi;
210}; 213};
211 214
212struct stfsm_seq { 215struct stfsm_seq {
@@ -692,6 +695,47 @@ static int stfsm_init(struct stfsm *fsm)
692 return 0; 695 return 0;
693} 696}
694 697
698static void stfsm_fetch_platform_configs(struct platform_device *pdev)
699{
700 struct stfsm *fsm = platform_get_drvdata(pdev);
701 struct device_node *np = pdev->dev.of_node;
702 struct regmap *regmap;
703 uint32_t boot_device_reg;
704 uint32_t boot_device_spi;
705 uint32_t boot_device; /* Value we read from *boot_device_reg */
706 int ret;
707
708 /* Booting from SPI NOR Flash is the default */
709 fsm->booted_from_spi = true;
710
711 regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
712 if (IS_ERR(regmap))
713 goto boot_device_fail;
714
715 /* Where in the syscon the boot device information lives */
716 ret = of_property_read_u32(np, "st,boot-device-reg", &boot_device_reg);
717 if (ret)
718 goto boot_device_fail;
719
720 /* Boot device value when booted from SPI NOR */
721 ret = of_property_read_u32(np, "st,boot-device-spi", &boot_device_spi);
722 if (ret)
723 goto boot_device_fail;
724
725 ret = regmap_read(regmap, boot_device_reg, &boot_device);
726 if (ret)
727 goto boot_device_fail;
728
729 if (boot_device != boot_device_spi)
730 fsm->booted_from_spi = false;
731
732 return;
733
734boot_device_fail:
735 dev_warn(&pdev->dev,
736 "failed to fetch boot device, assuming boot from SPI\n");
737}
738
695static int stfsm_probe(struct platform_device *pdev) 739static int stfsm_probe(struct platform_device *pdev)
696{ 740{
697 struct device_node *np = pdev->dev.of_node; 741 struct device_node *np = pdev->dev.of_node;
@@ -734,6 +778,8 @@ static int stfsm_probe(struct platform_device *pdev)
734 return ret; 778 return ret;
735 } 779 }
736 780
781 stfsm_fetch_platform_configs(pdev);
782
737 /* Detect SPI FLASH device */ 783 /* Detect SPI FLASH device */
738 info = stfsm_jedec_probe(fsm); 784 info = stfsm_jedec_probe(fsm);
739 if (!info) 785 if (!info)