blob: 058dcf11740423569c13a4cd8e5957aa09afb0fd [file] [log] [blame]
Lukasz Majewski44a6ac92013-03-05 12:10:17 +01001/*
2 * Copyright (C) 2011 Samsung Electrnoics
3 * Lukasz Majewski <l.majewski@samsung.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Lukasz Majewski44a6ac92013-03-05 12:10:17 +01006 */
7
8#ifndef __USB_MASS_STORAGE_H__
9#define __USB_MASS_STORAGE_H__
10
11#define SECTOR_SIZE 0x200
Lukasz Majewski44a6ac92013-03-05 12:10:17 +010012#include <mmc.h>
Lukasz Majewski0c635232013-09-17 15:58:21 +020013#include <linux/usb/composite.h>
Lukasz Majewski44a6ac92013-03-05 12:10:17 +010014
Przemyslaw Marczak674b1a62013-10-23 14:30:42 +020015#ifndef UMS_START_SECTOR
16#define UMS_START_SECTOR 0
17#endif
Lukasz Majewski44a6ac92013-03-05 12:10:17 +010018
Przemyslaw Marczak674b1a62013-10-23 14:30:42 +020019#ifndef UMS_NUM_SECTORS
20#define UMS_NUM_SECTORS 0
21#endif
22
Przemyslaw Marczake92cc562014-01-07 15:08:37 +010023/* Wait at maximum 60 seconds for cable connection */
24#define UMS_CABLE_READY_TIMEOUT 60
25
Przemyslaw Marczak674b1a62013-10-23 14:30:42 +020026struct ums {
27 int (*read_sector)(struct ums *ums_dev,
Lukasz Majewski44a6ac92013-03-05 12:10:17 +010028 ulong start, lbaint_t blkcnt, void *buf);
Przemyslaw Marczak674b1a62013-10-23 14:30:42 +020029 int (*write_sector)(struct ums *ums_dev,
Lukasz Majewski44a6ac92013-03-05 12:10:17 +010030 ulong start, lbaint_t blkcnt, const void *buf);
Przemyslaw Marczak3dab7302013-10-23 14:30:44 +020031 unsigned int start_sector;
32 unsigned int num_sectors;
Lukasz Majewski44a6ac92013-03-05 12:10:17 +010033 const char *name;
Przemyslaw Marczak674b1a62013-10-23 14:30:42 +020034 struct mmc *mmc;
Lukasz Majewski44a6ac92013-03-05 12:10:17 +010035};
36
Przemyslaw Marczak674b1a62013-10-23 14:30:42 +020037extern struct ums *ums;
38
39int fsg_init(struct ums *);
Mateusz Zalegad862f892013-10-04 19:22:26 +020040void fsg_cleanup(void);
Przemyslaw Marczak674b1a62013-10-23 14:30:42 +020041struct ums *ums_init(unsigned int);
Mateusz Zalegad862f892013-10-04 19:22:26 +020042int fsg_main_thread(void *);
Lukasz Majewski44a6ac92013-03-05 12:10:17 +010043
Lukasz Majewski0c635232013-09-17 15:58:21 +020044#ifdef CONFIG_USB_GADGET_MASS_STORAGE
45int fsg_add(struct usb_configuration *c);
46#else
47int fsg_add(struct usb_configuration *c)
48{
49 return 0;
50}
51#endif
Lukasz Majewski44a6ac92013-03-05 12:10:17 +010052#endif /* __USB_MASS_STORAGE_H__ */