diff options
author | Eric Anholt <eric@anholt.net> | 2015-05-13 14:35:41 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2015-06-23 17:02:37 -0700 |
commit | ec43ee9ffa7967bd8d3111c539f60ce0c1c9ef4c (patch) | |
tree | b45560bc934f1e8f24511516092b7eaddceb5c92 | |
parent | d0d5beea146588ac94b08bd48496987191d76568 (diff) | |
download | linux-ec43ee9ffa7967bd8d3111c539f60ce0c1c9ef4c.tar.gz |
ARM: BCM2709: Make the upstream-targeted mbox functions work on 2709 instead.
-rw-r--r-- | drivers/firmware/Makefile | 2 | ||||
-rw-r--r-- | drivers/firmware/raspberrypi.c | 106 | ||||
-rw-r--r-- | include/soc/bcm2835/raspberrypi-firmware-property.h | 4 |
3 files changed, 21 insertions, 91 deletions
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile index 41ced2885b46..78d4b6fb978d 100644 --- a/drivers/firmware/Makefile +++ b/drivers/firmware/Makefile @@ -13,7 +13,7 @@ obj-$(CONFIG_ISCSI_IBFT) += iscsi_ibft.o obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_QCOM_SCM) += qcom_scm.o CFLAGS_qcom_scm.o :=$(call as-instr,.arch_extension sec,-DREQUIRES_SEC=1) -obj-$(CONFIG_BCM2835_MBOX) += raspberrypi.o +obj-$(CONFIG_BCM2708_MBOX) += raspberrypi.o obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ obj-$(CONFIG_EFI) += efi/ diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index d612815fa106..9068b5842aba 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -15,6 +15,7 @@ #include <linux/mailbox_client.h> #include <linux/module.h> #include <linux/of_platform.h> +#include <linux/platform_data/mailbox-bcm2708.h> #include <linux/platform_device.h> #include <soc/bcm2835/raspberrypi-firmware-property.h> @@ -23,41 +24,30 @@ #define MBOX_DATA28(msg) ((msg) & ~0xf) #define MBOX_CHAN_PROPERTY 8 -struct rpi_firmware { - struct mbox_client cl; - struct mbox_chan *chan; /* The property channel. */ - struct completion c; - u32 enabled; -}; - static DEFINE_MUTEX(transaction_lock); -static void response_callback(struct mbox_client *cl, void *msg) -{ - struct rpi_firmware *fw = container_of(cl, struct rpi_firmware, cl); - complete(&fw->c); -} - /* * Sends a request to the firmware through the BCM2835 mailbox driver, * and synchronously waits for the reply. */ static int -rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data) +rpi_firmware_transaction(u32 chan, u32 data) { - u32 message = MBOX_MSG(chan, data); int ret; WARN_ON(data & 0xf); mutex_lock(&transaction_lock); - reinit_completion(&fw->c); - ret = mbox_send_message(fw->chan, &message); - if (ret >= 0) { - wait_for_completion(&fw->c); - ret = 0; + ret = bcm_mailbox_write(chan, data); + if (ret == 0) { + u32 ret; + + ret = bcm_mailbox_read(chan, &ret); + if (ret != 0) + pr_err("rpi_firmware_transaction() failed to read\n"); + } else { - dev_err(fw->cl.dev, "mbox_send_message returned %d\n", ret); + pr_err("rpi_firmware_transaction() failed to write\n"); } mutex_unlock(&transaction_lock); @@ -78,24 +68,19 @@ rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data) * See struct rpi_firmware_property_tag_header for the per-tag * structure. */ -int rpi_firmware_property_list(struct device_node *of_node, +int rpi_firmware_property_list(struct device *dev, void *data, size_t tag_size) { - struct platform_device *pdev = of_find_device_by_node(of_node); - struct rpi_firmware *fw = platform_get_drvdata(pdev); size_t size = tag_size + 12; u32 *buf; dma_addr_t bus_addr; int ret = 0; - if (!fw) - return -EPROBE_DEFER; - /* Packets are processed a dword at a time. */ if (size & 3) return -EINVAL; - buf = dma_alloc_coherent(fw->cl.dev, PAGE_ALIGN(size), &bus_addr, + buf = dma_alloc_coherent(dev, PAGE_ALIGN(size), &bus_addr, GFP_ATOMIC); if (!buf) return -ENOMEM; @@ -109,7 +94,7 @@ int rpi_firmware_property_list(struct device_node *of_node, buf[size / 4 - 1] = RPI_FIRMWARE_PROPERTY_END; wmb(); - ret = rpi_firmware_transaction(fw, MBOX_CHAN_PROPERTY, bus_addr); + ret = rpi_firmware_transaction(MBOX_CHAN_PROPERTY, bus_addr); rmb(); memcpy(data, &buf[2], tag_size); @@ -119,12 +104,12 @@ int rpi_firmware_property_list(struct device_node *of_node, * error, if there were multiple tags in the request. * But single-tag is the most common, so go with it. */ - dev_err(fw->cl.dev, "Request 0x%08x returned status 0x%08x\n", + dev_err(dev, "Request 0x%08x returned status 0x%08x\n", buf[2], buf[1]); ret = -EINVAL; } - dma_free_coherent(fw->cl.dev, PAGE_ALIGN(size), buf, bus_addr); + dma_free_coherent(dev, PAGE_ALIGN(size), buf, bus_addr); return ret; } @@ -144,7 +129,7 @@ EXPORT_SYMBOL_GPL(rpi_firmware_property_list); * rpi_firmware_property_list() to avoid some of the * boilerplate in property calls. */ -int rpi_firmware_property(struct device_node *of_node, +int rpi_firmware_property(struct device *dev, u32 tag, void *tag_data, size_t buf_size) { /* Single tags are very small (generally 8 bytes), so the @@ -161,7 +146,7 @@ int rpi_firmware_property(struct device_node *of_node, memcpy(data + sizeof(struct rpi_firmware_property_tag_header), tag_data, buf_size); - ret = rpi_firmware_property_list(of_node, &data, sizeof(data)); + ret = rpi_firmware_property_list(dev, &data, sizeof(data)); memcpy(tag_data, data + sizeof(struct rpi_firmware_property_tag_header), buf_size); @@ -170,61 +155,6 @@ int rpi_firmware_property(struct device_node *of_node, } EXPORT_SYMBOL_GPL(rpi_firmware_property); -static int rpi_firmware_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct rpi_firmware *fw; - - fw = devm_kzalloc(dev, sizeof(*fw), GFP_KERNEL); - if (!fw) - return -ENOMEM; - - fw->cl.dev = dev; - fw->cl.rx_callback = response_callback; - fw->cl.tx_block = true; - - fw->chan = mbox_request_channel(&fw->cl, 0); - if (IS_ERR(fw->chan)) { - int ret = PTR_ERR(fw->chan); - if (ret != -EPROBE_DEFER) - dev_err(dev, "Failed to get mbox channel: %d\n", ret); - return ret; - } - - init_completion(&fw->c); - - dev_info(dev, "Firmware driver\n"); - platform_set_drvdata(pdev, fw); - - return 0; -} - -static int rpi_firmware_remove(struct platform_device *pdev) -{ - struct rpi_firmware *fw = platform_get_drvdata(pdev); - - mbox_free_channel(fw->chan); - - return 0; -} - -static const struct of_device_id rpi_firmware_of_match[] = { - { .compatible = "raspberrypi,firmware", }, - {}, -}; -MODULE_DEVICE_TABLE(of, rpi_firmware_of_match); - -static struct platform_driver rpi_firmware_driver = { - .driver = { - .name = "raspberrypi-firmware", - .owner = THIS_MODULE, - .of_match_table = rpi_firmware_of_match, - }, - .probe = rpi_firmware_probe, - .remove = rpi_firmware_remove, -}; -module_platform_driver(rpi_firmware_driver); - MODULE_AUTHOR("Eric Anholt <eric@anholt.net>"); MODULE_DESCRIPTION("Raspberry Pi firmware driver"); MODULE_LICENSE("GPL v2"); diff --git a/include/soc/bcm2835/raspberrypi-firmware-property.h b/include/soc/bcm2835/raspberrypi-firmware-property.h index b007e924d5dc..c5ff1582bf40 100644 --- a/include/soc/bcm2835/raspberrypi-firmware-property.h +++ b/include/soc/bcm2835/raspberrypi-firmware-property.h @@ -106,7 +106,7 @@ enum rpi_firmware_property_tag { RPI_FIRMWARE_GET_DMA_CHANNELS = 0x00060001, }; -int rpi_firmware_property(struct device_node *of_node, +int rpi_firmware_property(struct device *dev, u32 tag, void *data, size_t len); -int rpi_firmware_property_list(struct device_node *of_node, +int rpi_firmware_property_list(struct device *dev, void *data, size_t tag_size); |