linux/drivers/misc/ti-st/st_kim.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  Shared Transport Line discipline driver Core
 *	Init Manager module responsible for GPIO control
 *	and firmware download
 *  Copyright (C) 2009-2010 Texas Instruments
 *  Author: Pavan Savoy <[email protected]>
 */

#define pr_fmt(fmt)
#include <linux/platform_device.h>
#include <linux/jiffies.h>
#include <linux/firmware.h>
#include <linux/delay.h>
#include <linux/wait.h>
#include <linux/gpio.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/sched.h>
#include <linux/sysfs.h>
#include <linux/tty.h>

#include <linux/skbuff.h>
#include <linux/ti_wilink_st.h>
#include <linux/module.h>

#define MAX_ST_DEVICES
static struct platform_device *st_kim_devices[MAX_ST_DEVICES];

/**********************************************************************/
/* internal functions */

/*
 * st_get_plat_device -
 *	function which returns the reference to the platform device
 *	requested by id. As of now only 1 such device exists (id=0)
 *	the context requesting for reference can get the id to be
 *	requested by a. The protocol driver which is registering or
 *	b. the tty device which is opened.
 */
static struct platform_device *st_get_plat_device(int id)
{}

/*
 * validate_firmware_response -
 *	function to return whether the firmware response was proper
 *	in case of error don't complete so that waiting for proper
 *	response times out
 */
static void validate_firmware_response(struct kim_data_s *kim_gdata)
{}

/*
 * check for data len received inside kim_int_recv
 * most often hit the last case to update state to waiting for data
 */
static inline int kim_check_data_len(struct kim_data_s *kim_gdata, int len)
{}

/*
 * kim_int_recv - receive function called during firmware download
 *	firmware download responses on different UART drivers
 *	have been observed to come in bursts of different
 *	tty_receive and hence the logic
 */
static void kim_int_recv(struct kim_data_s *kim_gdata, const u8 *ptr,
			 size_t count)
{}

static long read_local_version(struct kim_data_s *kim_gdata, char *bts_scr_name)
{}

static void skip_change_remote_baud(unsigned char **ptr, long *len)
{}

/*
 * download_firmware -
 *	internal function which parses through the .bts firmware
 *	script file intreprets SEND, DELAY actions only as of now
 */
static long download_firmware(struct kim_data_s *kim_gdata)
{}

/**********************************************************************/
/* functions called from ST core */
/* called from ST Core, when REG_IN_PROGRESS (registration in progress)
 * can be because of
 * 1. response to read local version
 * 2. during send/recv's of firmware download
 */
void st_kim_recv(void *disc_data, const u8 *data, size_t count)
{}

/*
 * to signal completion of line discipline installation
 * called from ST Core, upon tty_open
 */
void st_kim_complete(void *kim_data)
{}

/*
 * st_kim_start - called from ST Core upon 1st registration
 *	This involves toggling the chip enable gpio, reading
 *	the firmware version from chip, forming the fw file name
 *	based on the chip version, requesting the fw, parsing it
 *	and perform download(send/recv).
 */
long st_kim_start(void *kim_data)
{}

/*
 * st_kim_stop - stop communication with chip.
 *	This can be called from ST Core/KIM, on the-
 *	(a) last un-register when chip need not be powered there-after,
 *	(b) upon failure to either install ldisc or download firmware.
 *	The function is responsible to (a) notify UIM about un-installation,
 *	(b) flush UART if the ldisc was installed.
 *	(c) reset BT_EN - pull down nshutdown at the end.
 *	(d) invoke platform's chip disabling routine.
 */
long st_kim_stop(void *kim_data)
{}

/**********************************************************************/
/* functions called from subsystems */
/* called when debugfs entry is read from */

static int version_show(struct seq_file *s, void *unused)
{}

static int list_show(struct seq_file *s, void *unused)
{}

static ssize_t show_install(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

#ifdef DEBUG
static ssize_t store_dev_name(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{
	struct kim_data_s *kim_data = dev_get_drvdata(dev);
	pr_debug("storing dev name >%s<", buf);
	strscpy(kim_data->dev_name, buf, sizeof(kim_data->dev_name));
	pr_debug("stored dev name >%s<", kim_data->dev_name);
	return count;
}

static ssize_t store_baud_rate(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{
	struct kim_data_s *kim_data = dev_get_drvdata(dev);
	pr_debug("storing baud rate >%s<", buf);
	sscanf(buf, "%ld", &kim_data->baud_rate);
	pr_debug("stored baud rate >%ld<", kim_data->baud_rate);
	return count;
}
#endif	/* if DEBUG */

static ssize_t show_dev_name(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t show_baud_rate(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

static ssize_t show_flow_cntrl(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

/* structures specific for sysfs entries */
static struct kobj_attribute ldisc_install =;

static struct kobj_attribute uart_dev_name =__ATTR(dev_name, 0644, (void *)show_dev_name, (void *)store_dev_name);
#else
__ATTR(dev_name, 0444, (void *)show_dev_name, NULL);
#endif

static struct kobj_attribute uart_baud_rate =__ATTR(baud_rate, 0644, (void *)show_baud_rate, (void *)store_baud_rate);
#else
__ATTR(baud_rate, 0444, (void *)show_baud_rate, NULL);
#endif

static struct kobj_attribute uart_flow_cntrl =;

static struct attribute *uim_attrs[] =;

static const struct attribute_group uim_attr_grp =;

/*
 * st_kim_ref - reference the core's data
 *	This references the per-ST platform device in the arch/xx/
 *	board-xx.c file.
 *	This would enable multiple such platform devices to exist
 *	on a given platform
 */
void st_kim_ref(struct st_data_s **core_data, int id)
{}

DEFINE_SHOW_ATTRIBUTE();
DEFINE_SHOW_ATTRIBUTE();

/**********************************************************************/
/* functions called from platform device driver subsystem
 * need to have a relevant platform device entry in the platform's
 * board-*.c file
 */

static struct dentry *kim_debugfs_dir;
static int kim_probe(struct platform_device *pdev)
{}

static void kim_remove(struct platform_device *pdev)
{}

static int kim_suspend(struct platform_device *pdev, pm_message_t state)
{}

static int kim_resume(struct platform_device *pdev)
{}

/**********************************************************************/
/* entry point for ST KIM module, called in from ST Core */
static struct platform_driver kim_platform_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();