brintos

brintos / linux-shallow public Read only

0
0
Text · 2.8 KiB · bb6b712 Raw
96 lines · c
1/* SPDX-License-Identifier: GPL-2.02 *3 * Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com/4 */5 6#ifndef __LINUX_MTD_HYPERBUS_H__7#define __LINUX_MTD_HYPERBUS_H__8 9#include <linux/mtd/map.h>10 11/* HyperBus command bits */12#define HYPERBUS_RW	0x80	/* R/W# */13#define HYPERBUS_RW_WRITE 014#define HYPERBUS_RW_READ 0x8015#define HYPERBUS_AS	0x40	/* Address Space */16#define HYPERBUS_AS_MEM	017#define HYPERBUS_AS_REG	0x4018#define HYPERBUS_BT	0x20	/* Burst Type */19#define HYPERBUS_BT_WRAPPED 020#define HYPERBUS_BT_LINEAR 0x2021 22enum hyperbus_memtype {23	HYPERFLASH,24	HYPERRAM,25};26 27/**28 * struct hyperbus_device - struct representing HyperBus slave device29 * @map: map_info struct for accessing MMIO HyperBus flash memory30 * @np: pointer to HyperBus slave device node31 * @mtd: pointer to MTD struct32 * @ctlr: pointer to HyperBus controller struct33 * @memtype: type of memory device: HyperFlash or HyperRAM34 * @priv: pointer to controller specific per device private data35 */36 37struct hyperbus_device {38	struct map_info map;39	struct device_node *np;40	struct mtd_info *mtd;41	struct hyperbus_ctlr *ctlr;42	enum hyperbus_memtype memtype;43	void *priv;44};45 46/**47 * struct hyperbus_ops - struct representing custom HyperBus operations48 * @read16: read 16 bit of data from flash in a single burst. Used to read49 *          from non default address space, such as ID/CFI space50 * @write16: write 16 bit of data to flash in a single burst. Used to51 *           send cmd to flash or write single 16 bit word at a time.52 * @copy_from: copy data from flash memory53 * @copy_to: copy data to flash memory54 * @calibrate: calibrate HyperBus controller55 */56 57struct hyperbus_ops {58	u16 (*read16)(struct hyperbus_device *hbdev, unsigned long addr);59	void (*write16)(struct hyperbus_device *hbdev,60			unsigned long addr, u16 val);61	void (*copy_from)(struct hyperbus_device *hbdev, void *to,62			  unsigned long from, ssize_t len);63	void (*copy_to)(struct hyperbus_device *dev, unsigned long to,64			const void *from, ssize_t len);65	int (*calibrate)(struct hyperbus_device *dev);66};67 68/**69 * struct hyperbus_ctlr - struct representing HyperBus controller70 * @dev: pointer to HyperBus controller device71 * @calibrated: flag to indicate ctlr calibration sequence is complete72 * @ops: HyperBus controller ops73 */74struct hyperbus_ctlr {75	struct device *dev;76	bool calibrated;77 78	const struct hyperbus_ops *ops;79};80 81/**82 * hyperbus_register_device - probe and register a HyperBus slave memory device83 * @hbdev: hyperbus_device struct with dev, np and ctlr field populated84 *85 * Return: 0 for success, others for failure.86 */87int hyperbus_register_device(struct hyperbus_device *hbdev);88 89/**90 * hyperbus_unregister_device - deregister HyperBus slave memory device91 * @hbdev: hyperbus_device to be unregistered92 */93void hyperbus_unregister_device(struct hyperbus_device *hbdev);94 95#endif /* __LINUX_MTD_HYPERBUS_H__ */96