Skip to content

Commit 0d7c5f2

Browse files
Pavan Savoygregkh
authored andcommitted
drivers:misc:ti-st: platform hooks for chip states
Certain platform specific or Host-WiLink Interface specific actions would be required to be taken when the chip is being enabled and after the chip is disabled such as configuration of the mux modes for the GPIO of host connected to the nshutdown of the chip or relinquishing UART after the chip is disabled. Similar actions can also be taken when the chip is in deep sleep or when the chip is awake. Performance enhancements such as configuring the host to run faster when chip is awake and slower when chip is asleep can also be made here. Signed-off-by: Pavan Savoy <pavan_savoy@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 5926cef commit 0d7c5f2

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,17 @@ long st_kim_start(void *kim_data)
434434
{
435435
long err = 0;
436436
long retry = POR_RETRY_COUNT;
437+
struct ti_st_plat_data *pdata;
437438
struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
438439

439440
pr_info(" %s", __func__);
441+
pdata = kim_gdata->kim_pdev->dev.platform_data;
440442

441443
do {
444+
/* platform specific enabling code here */
445+
if (pdata->chip_enable)
446+
pdata->chip_enable(kim_gdata);
447+
442448
/* Configure BT nShutdown to HIGH state */
443449
gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);
444450
mdelay(5); /* FIXME: a proper toggle */
@@ -489,6 +495,8 @@ long st_kim_stop(void *kim_data)
489495
{
490496
long err = 0;
491497
struct kim_data_s *kim_gdata = (struct kim_data_s *)kim_data;
498+
struct ti_st_plat_data *pdata =
499+
kim_gdata->kim_pdev->dev.platform_data;
492500

493501
INIT_COMPLETION(kim_gdata->ldisc_installed);
494502

@@ -515,6 +523,10 @@ long st_kim_stop(void *kim_data)
515523
gpio_set_value(kim_gdata->nshutdown, GPIO_HIGH);
516524
mdelay(1);
517525
gpio_set_value(kim_gdata->nshutdown, GPIO_LOW);
526+
527+
/* platform specific disable */
528+
if (pdata->chip_disable)
529+
pdata->chip_disable(kim_gdata);
518530
return err;
519531
}
520532

‎drivers/misc/ti-st/st_ll.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define pr_fmt(fmt) "(stll) :" fmt
2323
#include <linux/skbuff.h>
2424
#include <linux/module.h>
25+
#include <linux/platform_device.h>
2526
#include <linux/ti_wilink_st.h>
2627

2728
/**********************************************************************/
@@ -37,6 +38,9 @@ static void send_ll_cmd(struct st_data_s *st_data,
3738

3839
static void ll_device_want_to_sleep(struct st_data_s *st_data)
3940
{
41+
struct kim_data_s *kim_data;
42+
struct ti_st_plat_data *pdata;
43+
4044
pr_debug("%s", __func__);
4145
/* sanity check */
4246
if (st_data->ll_state != ST_LL_AWAKE)
@@ -46,10 +50,19 @@ static void ll_device_want_to_sleep(struct st_data_s *st_data)
4650
send_ll_cmd(st_data, LL_SLEEP_ACK);
4751
/* update state */
4852
st_data->ll_state = ST_LL_ASLEEP;
53+
54+
/* communicate to platform about chip asleep */
55+
kim_data = st_data->kim_data;
56+
pdata = kim_data->kim_pdev->dev.platform_data;
57+
if (pdata->chip_asleep)
58+
pdata->chip_asleep(NULL);
4959
}
5060

5161
static void ll_device_want_to_wakeup(struct st_data_s *st_data)
5262
{
63+
struct kim_data_s *kim_data;
64+
struct ti_st_plat_data *pdata;
65+
5366
/* diff actions in diff states */
5467
switch (st_data->ll_state) {
5568
case ST_LL_ASLEEP:
@@ -70,6 +83,12 @@ static void ll_device_want_to_wakeup(struct st_data_s *st_data)
7083
}
7184
/* update state */
7285
st_data->ll_state = ST_LL_AWAKE;
86+
87+
/* communicate to platform about chip wakeup */
88+
kim_data = st_data->kim_data;
89+
pdata = kim_data->kim_pdev->dev.platform_data;
90+
if (pdata->chip_asleep)
91+
pdata->chip_awake(NULL);
7392
}
7493

7594
/**********************************************************************/

‎include/linux/ti_wilink_st.h‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,39 @@ struct gps_event_hdr {
410410
u16 plen;
411411
} __attribute__ ((packed));
412412

413-
/* platform data */
413+
/**
414+
* struct ti_st_plat_data - platform data shared between ST driver and
415+
* platform specific board file which adds the ST device.
416+
* @nshutdown_gpio: Host's GPIO line to which chip's BT_EN is connected.
417+
* @dev_name: The UART/TTY name to which chip is interfaced. (eg: /dev/ttyS1)
418+
* @flow_cntrl: Should always be 1, since UART's CTS/RTS is used for PM
419+
* purposes.
420+
* @baud_rate: The baud rate supported by the Host UART controller, this will
421+
* be shared across with the chip via a HCI VS command from User-Space Init
422+
* Mgr application.
423+
* @suspend:
424+
* @resume: legacy PM routines hooked to platform specific board file, so as
425+
* to take chip-host interface specific action.
426+
* @chip_enable:
427+
* @chip_disable: Platform/Interface specific mux mode setting, GPIO
428+
* configuring, Host side PM disabling etc.. can be done here.
429+
* @chip_asleep:
430+
* @chip_awake: Chip specific deep sleep states is communicated to Host
431+
* specific board-xx.c to take actions such as cut UART clocks when chip
432+
* asleep or run host faster when chip awake etc..
433+
*
434+
*/
414435
struct ti_st_plat_data {
415436
long nshutdown_gpio;
416437
unsigned char dev_name[UART_DEV_NAME_LEN]; /* uart name */
417438
unsigned char flow_cntrl; /* flow control flag */
418439
unsigned long baud_rate;
419440
int (*suspend)(struct platform_device *, pm_message_t);
420441
int (*resume)(struct platform_device *);
442+
int (*chip_enable) (struct kim_data_s *);
443+
int (*chip_disable) (struct kim_data_s *);
444+
int (*chip_asleep) (struct kim_data_s *);
445+
int (*chip_awake) (struct kim_data_s *);
421446
};
422447

423448
#endif /* TI_WILINK_ST_H */

0 commit comments

Comments
 (0)