|
@@ -296,3 +296,138 @@ static void _add_clkdev(struct omap_device *od, const char *clk_alias,
|
|
|
*
|
|
|
* No return value.
|
|
|
*/
|
|
|
+static void _add_hwmod_clocks_clkdev(struct omap_device *od,
|
|
|
+ struct omap_hwmod *oh)
|
|
|
+{
|
|
|
+ int i;
|
|
|
+
|
|
|
+ _add_clkdev(od, "fck", oh->main_clk);
|
|
|
+
|
|
|
+ for (i = 0; i < oh->opt_clks_cnt; i++)
|
|
|
+ _add_clkdev(od, oh->opt_clks[i].role, oh->opt_clks[i].clk);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * omap_device_build_from_dt - build an omap_device with multiple hwmods
|
|
|
+ * @pdev_name: name of the platform_device driver to use
|
|
|
+ * @pdev_id: this platform_device's connection ID
|
|
|
+ * @oh: ptr to the single omap_hwmod that backs this omap_device
|
|
|
+ * @pdata: platform_data ptr to associate with the platform_device
|
|
|
+ * @pdata_len: amount of memory pointed to by @pdata
|
|
|
+ * @pm_lats: pointer to a omap_device_pm_latency array for this device
|
|
|
+ * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
|
|
|
+ * @is_early_device: should the device be registered as an early device or not
|
|
|
+ *
|
|
|
+ * Function for building an omap_device already registered from device-tree
|
|
|
+ *
|
|
|
+ * Returns 0 or PTR_ERR() on error.
|
|
|
+ */
|
|
|
+static int omap_device_build_from_dt(struct platform_device *pdev)
|
|
|
+{
|
|
|
+ struct omap_hwmod **hwmods;
|
|
|
+ struct omap_device *od;
|
|
|
+ struct omap_hwmod *oh;
|
|
|
+ struct device_node *node = pdev->dev.of_node;
|
|
|
+ const char *oh_name;
|
|
|
+ int oh_cnt, i, ret = 0;
|
|
|
+
|
|
|
+ oh_cnt = of_property_count_strings(node, "ti,hwmods");
|
|
|
+ if (!oh_cnt || IS_ERR_VALUE(oh_cnt)) {
|
|
|
+ dev_dbg(&pdev->dev, "No 'hwmods' to build omap_device\n");
|
|
|
+ return -ENODEV;
|
|
|
+ }
|
|
|
+
|
|
|
+ hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
|
|
|
+ if (!hwmods) {
|
|
|
+ ret = -ENOMEM;
|
|
|
+ goto odbfd_exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (i = 0; i < oh_cnt; i++) {
|
|
|
+ of_property_read_string_index(node, "ti,hwmods", i, &oh_name);
|
|
|
+ oh = omap_hwmod_lookup(oh_name);
|
|
|
+ if (!oh) {
|
|
|
+ dev_err(&pdev->dev, "Cannot lookup hwmod '%s'\n",
|
|
|
+ oh_name);
|
|
|
+ ret = -EINVAL;
|
|
|
+ goto odbfd_exit1;
|
|
|
+ }
|
|
|
+ hwmods[i] = oh;
|
|
|
+ }
|
|
|
+
|
|
|
+ od = omap_device_alloc(pdev, hwmods, oh_cnt, NULL, 0);
|
|
|
+ if (!od) {
|
|
|
+ dev_err(&pdev->dev, "Cannot allocate omap_device for :%s\n",
|
|
|
+ oh_name);
|
|
|
+ ret = PTR_ERR(od);
|
|
|
+ goto odbfd_exit1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Fix up missing resource names */
|
|
|
+ for (i = 0; i < pdev->num_resources; i++) {
|
|
|
+ struct resource *r = &pdev->resource[i];
|
|
|
+
|
|
|
+ if (r->name == NULL)
|
|
|
+ r->name = dev_name(&pdev->dev);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (of_get_property(node, "ti,no_idle_on_suspend", NULL))
|
|
|
+ omap_device_disable_idle_on_suspend(pdev);
|
|
|
+
|
|
|
+ pdev->dev.pm_domain = &omap_device_pm_domain;
|
|
|
+
|
|
|
+odbfd_exit1:
|
|
|
+ kfree(hwmods);
|
|
|
+odbfd_exit:
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
+static int _omap_device_notifier_call(struct notifier_block *nb,
|
|
|
+ unsigned long event, void *dev)
|
|
|
+{
|
|
|
+ struct platform_device *pdev = to_platform_device(dev);
|
|
|
+ struct omap_device *od;
|
|
|
+
|
|
|
+ switch (event) {
|
|
|
+ case BUS_NOTIFY_DEL_DEVICE:
|
|
|
+ if (pdev->archdata.od)
|
|
|
+ omap_device_delete(pdev->archdata.od);
|
|
|
+ break;
|
|
|
+ case BUS_NOTIFY_ADD_DEVICE:
|
|
|
+ if (pdev->dev.of_node)
|
|
|
+ omap_device_build_from_dt(pdev);
|
|
|
+ /* fall through */
|
|
|
+ default:
|
|
|
+ od = to_omap_device(pdev);
|
|
|
+ if (od)
|
|
|
+ od->_driver_status = event;
|
|
|
+ }
|
|
|
+
|
|
|
+ return NOTIFY_DONE;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/* Public functions for use by core code */
|
|
|
+
|
|
|
+/**
|
|
|
+ * omap_device_get_context_loss_count - get lost context count
|
|
|
+ * @od: struct omap_device *
|
|
|
+ *
|
|
|
+ * Using the primary hwmod, query the context loss count for this
|
|
|
+ * device.
|
|
|
+ *
|
|
|
+ * Callers should consider context for this device lost any time this
|
|
|
+ * function returns a value different than the value the caller got
|
|
|
+ * the last time it called this function.
|
|
|
+ *
|
|
|
+ * If any hwmods exist for the omap_device assoiated with @pdev,
|
|
|
+ * return the context loss counter for that hwmod, otherwise return
|
|
|
+ * zero.
|
|
|
+ */
|
|
|
+int omap_device_get_context_loss_count(struct platform_device *pdev)
|
|
|
+{
|
|
|
+ struct omap_device *od;
|
|
|
+ u32 ret = 0;
|
|
|
+
|
|
|
+ od = to_omap_device(pdev);
|