[RFC PATCH 3/3] Enable BCM2835 mailbox support

Lubomir Rintel lkundrak at v3.sk
Mon Jun 30 09:06:40 PDT 2014


Hi Craig,

I'm possibly a bit late, but, as you probably know, I've only started
looking at the upcoming mailbox framework only recently.

On Fri, 2013-09-13 at 23:32 +1200, Craig McGeachie wrote:
> Implement BCM2835 CPU thermal sensor support.
> 
> Signed-off-by: Craig McGeachie <slapdau at yahoo.com.au>
...
> +static int do_message(struct bcm2835_therm *therm, dma_addr_t msg_handle)
> +{
> +	struct device *dev = therm->dev;
> +	struct ipc_client therm_mbox;
> +	void *channel;
> +	int ret = 0;
> +
> +	memset(&therm_mbox, 0, sizeof(therm_mbox));
> +	therm_mbox.chan_name = "bcm2835:property";
> +	therm_mbox.rxcb = bcm2835_rxcb;
> +	therm_mbox.cl_id = therm;
> +	mutex_lock(&therm->lock);
> +	INIT_COMPLETION(therm->comp);
> +	channel = ipc_request_channel(&therm_mbox);
> +	if (!channel) {
> +		dev_err(dev, "No ipc channel\n");
> +		ret = -EAGAIN;
> +		goto exit;
> +	}
> +	ipc_send_message(channel, (void *) msg_handle);
> +	wait_for_completion(&therm->comp);
> +	ipc_free_channel(channel);
> +exit:
> +	mutex_unlock(&therm->lock);
> +	return ret;
> +}
...
> +static int bcm2835_thermal_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct bcm2835_therm *therm = devm_kzalloc(dev, sizeof(*therm),
> +		GFP_KERNEL);
> +	if (!therm) {
> +		dev_err(dev, "Failed to allocate memory\n");
> +		return -ENOMEM;
> +	}
> +	therm->dev = dev;
> +	mutex_init(&therm->lock);
> +	init_completion(&therm->comp);
> +	therm->thermal_dev = thermal_zone_device_register("bcm2835_thermal", 1,
> +		0, therm, &ops, NULL, 0, 0);
> +	if (IS_ERR(therm->thermal_dev)) {
> +		dev_err(dev, "Unable to register the thermal device");
> +		return PTR_ERR(therm->thermal_dev);
> +	}
> +	platform_set_drvdata(pdev, therm);
> +	dev_info(dev, "%s enabled\n", pdev->name);
> +	return 0;
> +}

I'm wondering if there's a reason you're not getting the channel with
ipc_request_channel() (that would be mbox_request_channel() in current
version of the framework) at the probe time, but each time you send a
message with do_message()?

Thank you,
Lubo




More information about the linux-rpi-kernel mailing list