1 /* SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
6 #ifndef __LINUX_MTD_HYPERBUS_H__
7 #define __LINUX_MTD_HYPERBUS_H__
9 #include <linux/mtd/map.h>
11 enum hyperbus_memtype {
17 * struct hyperbus_device - struct representing HyperBus slave device
18 * @map: map_info struct for accessing MMIO HyperBus flash memory
19 * @np: pointer to HyperBus slave device node
20 * @mtd: pointer to MTD struct
21 * @ctlr: pointer to HyperBus controller struct
22 * @memtype: type of memory device: HyperFlash or HyperRAM
25 struct hyperbus_device {
27 struct device_node *np;
29 struct hyperbus_ctlr *ctlr;
30 enum hyperbus_memtype memtype;
34 * struct hyperbus_ops - struct representing custom HyperBus operations
35 * @read16: read 16 bit of data from flash in a single burst. Used to read
36 * from non default address space, such as ID/CFI space
37 * @write16: write 16 bit of data to flash in a single burst. Used to
38 * send cmd to flash or write single 16 bit word at a time.
39 * @copy_from: copy data from flash memory
40 * @copy_to: copy data to flash memory
41 * @calibrate: calibrate HyperBus controller
45 u16 (*read16)(struct hyperbus_device *hbdev, unsigned long addr);
46 void (*write16)(struct hyperbus_device *hbdev,
47 unsigned long addr, u16 val);
48 void (*copy_from)(struct hyperbus_device *hbdev, void *to,
49 unsigned long from, ssize_t len);
50 void (*copy_to)(struct hyperbus_device *dev, unsigned long to,
51 const void *from, ssize_t len);
52 int (*calibrate)(struct hyperbus_device *dev);
56 * struct hyperbus_ctlr - struct representing HyperBus controller
57 * @dev: pointer to HyperBus controller device
58 * @calibrated: flag to indicate ctlr calibration sequence is complete
59 * @ops: HyperBus controller ops
61 struct hyperbus_ctlr {
65 const struct hyperbus_ops *ops;
69 * hyperbus_register_device - probe and register a HyperBus slave memory device
70 * @hbdev: hyperbus_device struct with dev, np and ctlr field populated
72 * Return: 0 for success, others for failure.
74 int hyperbus_register_device(struct hyperbus_device *hbdev);
77 * hyperbus_unregister_device - deregister HyperBus slave memory device
78 * @hbdev: hyperbus_device to be unregistered
80 * Return: 0 for success, others for failure.
82 int hyperbus_unregister_device(struct hyperbus_device *hbdev);
84 #endif /* __LINUX_MTD_HYPERBUS_H__ */