linux/arch/arm/mach-omap2/omap_device.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0-only */
   2/*
   3 * omap_device headers
   4 *
   5 * Copyright (C) 2009 Nokia Corporation
   6 * Paul Walmsley
   7 *
   8 * Developed in collaboration with (alphabetical order): Benoit
   9 * Cousson, Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram
  10 * Pandita, Sakari Poussa, Anand Sawant, Santosh Shilimkar, Richard
  11 * Woodruff
  12 *
  13 * This type of functionality should be implemented as a proper
  14 * omap_bus/omap_device in Linux.
  15 *
  16 * omap_device differs from omap_hwmod in that it includes external
  17 * (e.g., board- and system-level) integration details.  omap_hwmod
  18 * stores hardware data that is invariant for a given OMAP chip.
  19 */
  20#ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
  21#define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_DEVICE_H
  22
  23#include <linux/kernel.h>
  24#include <linux/platform_device.h>
  25
  26#include "omap_hwmod.h"
  27
  28extern struct dev_pm_domain omap_device_pm_domain;
  29extern struct dev_pm_domain omap_device_fail_pm_domain;
  30
  31/* omap_device._state values */
  32#define OMAP_DEVICE_STATE_UNKNOWN       0
  33#define OMAP_DEVICE_STATE_ENABLED       1
  34#define OMAP_DEVICE_STATE_IDLE          2
  35#define OMAP_DEVICE_STATE_SHUTDOWN      3
  36
  37/* omap_device.flags values */
  38#define OMAP_DEVICE_SUSPENDED           BIT(0)
  39
  40/**
  41 * struct omap_device - omap_device wrapper for platform_devices
  42 * @pdev: platform_device
  43 * @hwmods: (one .. many per omap_device)
  44 * @hwmods_cnt: ARRAY_SIZE() of @hwmods
  45 * @_state: one of OMAP_DEVICE_STATE_* (see above)
  46 * @flags: device flags
  47 * @_driver_status: one of BUS_NOTIFY_*_DRIVER from <linux/device.h>
  48 *
  49 * Integrates omap_hwmod data into Linux platform_device.
  50 *
  51 * Field names beginning with underscores are for the internal use of
  52 * the omap_device code.
  53 *
  54 */
  55struct omap_device {
  56        struct platform_device          *pdev;
  57        struct omap_hwmod               **hwmods;
  58        unsigned long                   _driver_status;
  59        u8                              hwmods_cnt;
  60        u8                              _state;
  61        u8                              flags;
  62};
  63
  64/* Device driver interface (call via platform_data fn ptrs) */
  65
  66int omap_device_enable(struct platform_device *pdev);
  67int omap_device_idle(struct platform_device *pdev);
  68
  69/* Core code interface */
  70
  71struct omap_device *omap_device_alloc(struct platform_device *pdev,
  72                                      struct omap_hwmod **ohs, int oh_cnt);
  73void omap_device_delete(struct omap_device *od);
  74int omap_device_register(struct platform_device *pdev);
  75
  76struct device *omap_device_get_by_hwmod_name(const char *oh_name);
  77
  78/* OMAP PM interface */
  79int omap_device_get_context_loss_count(struct platform_device *pdev);
  80
  81/* Other */
  82
  83int omap_device_assert_hardreset(struct platform_device *pdev,
  84                                 const char *name);
  85int omap_device_deassert_hardreset(struct platform_device *pdev,
  86                                 const char *name);
  87
  88/* Get omap_device pointer from platform_device pointer */
  89static inline struct omap_device *to_omap_device(struct platform_device *pdev)
  90{
  91        return pdev ? pdev->archdata.od : NULL;
  92}
  93#endif
  94