Skip to content

Commit 742aa6c

Browse files
committed
soc: microchip: mpfs: enable access to the system controller's flash
The system controller has a flash that contains images used to reprogram the FPGA using IAP (In-Application Programming). Introduce a function that allows a driver with a reference to the system controller to get one to a flash device attached to it. Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
1 parent 98d62e9 commit 742aa6c

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

drivers/soc/microchip/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
config POLARFIRE_SOC_SYS_CTRL
22
tristate "POLARFIRE_SOC_SYS_CTRL"
33
depends on POLARFIRE_SOC_MAILBOX
4+
depends on MTD
45
help
56
This driver adds support for the PolarFire SoC (MPFS) system controller.
67

drivers/soc/microchip/mpfs-sys-controller.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <linux/kref.h>
1313
#include <linux/module.h>
1414
#include <linux/jiffies.h>
15+
#include <linux/mtd/mtd.h>
16+
#include <linux/spi/spi.h>
1517
#include <linux/interrupt.h>
1618
#include <linux/of.h>
1719
#include <linux/mailbox_client.h>
@@ -30,6 +32,7 @@ struct mpfs_sys_controller {
3032
struct mbox_client client;
3133
struct mbox_chan *chan;
3234
struct completion c;
35+
struct mtd_info *flash;
3336
struct kref consumers;
3437
};
3538

@@ -99,6 +102,12 @@ static void mpfs_sys_controller_put(void *data)
99102
kref_put(&sys_controller->consumers, mpfs_sys_controller_delete);
100103
}
101104

105+
struct mtd_info *mpfs_sys_controller_get_flash(struct mpfs_sys_controller *mpfs_client)
106+
{
107+
return mpfs_client->flash;
108+
}
109+
EXPORT_SYMBOL(mpfs_sys_controller_get_flash);
110+
102111
static struct platform_device subdevs[] = {
103112
{
104113
.name = "mpfs-rng",
@@ -114,12 +123,23 @@ static int mpfs_sys_controller_probe(struct platform_device *pdev)
114123
{
115124
struct device *dev = &pdev->dev;
116125
struct mpfs_sys_controller *sys_controller;
126+
struct device_node *np;
117127
int i, ret;
118128

119129
sys_controller = kzalloc(sizeof(*sys_controller), GFP_KERNEL);
120130
if (!sys_controller)
121131
return -ENOMEM;
122132

133+
np = of_parse_phandle(dev->of_node, "microchip,bitstream-flash", 0);
134+
if (!np)
135+
goto no_flash;
136+
137+
sys_controller->flash = of_get_mtd_device_by_node(np);
138+
of_node_put(np);
139+
if (IS_ERR(sys_controller->flash))
140+
return dev_err_probe(dev, PTR_ERR(sys_controller->flash), "Failed to get flash\n");
141+
142+
no_flash:
123143
sys_controller->client.dev = dev;
124144
sys_controller->client.rx_callback = mpfs_sys_controller_rx_callback;
125145
sys_controller->client.tx_block = 1U;

include/soc/microchip/mpfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ int mpfs_blocking_transaction(struct mpfs_sys_controller *mpfs_client, struct mp
3838

3939
struct mpfs_sys_controller *mpfs_sys_controller_get(struct device *dev);
4040

41+
struct mtd_info *mpfs_sys_controller_get_flash(struct mpfs_sys_controller *mpfs_client);
42+
4143
#endif /* if IS_ENABLED(CONFIG_POLARFIRE_SOC_SYS_CTRL) */
4244

4345
#if IS_ENABLED(CONFIG_MCHP_CLK_MPFS)

0 commit comments

Comments
 (0)