Commit 83ef41f0 authored by Pavan Savoy's avatar Pavan Savoy Committed by Greg Kroah-Hartman

staging: ti-st: mv headers to ti_wilink_st

move all the header information to ti_wilink_st.h.
This header would then not only serve the local modules like the st_core.c,
st_kim.c and st_ll.c but also the external modules/protocol drivers that are
dependent on the shared transport driver.
Modify the source files to include the new header ti_wilink_st.h,
Signed-off-by: default avatarPavan Savoy <pavan_savoy@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 5d702ea3
......@@ -24,7 +24,7 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include "st.h"
#include "ti_wilink_st.h"
#include "bt_drv.h"
/* Define this macro to get debug msg */
......
struct fm_event_hdr {
u8 plen;
} __attribute__ ((packed));
#define FM_MAX_FRAME_SIZE 0xFF /* TODO: */
#define FM_EVENT_HDR_SIZE 1 /* size of fm_event_hdr */
#define ST_FM_CH8_PKT 0x8
/* gps stuff */
struct gps_event_hdr {
u8 opcode;
u16 plen;
} __attribute__ ((packed));
/*
* Shared Transport Header file
* To be included by the protocol stack drivers for
* Texas Instruments BT,FM and GPS combo chip drivers
*
* Copyright (C) 2009 Texas Instruments
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef ST_H
#define ST_H
#include <linux/skbuff.h>
/* TODO:
* Move the following to tty.h upon acceptance
*/
#define N_TI_WL 20 /* Ldisc for TI's WL BT, FM, GPS combo chips */
/**
* enum kim_gpio_state - Few protocols such as FM have ACTIVE LOW
* gpio states for their chip/core enable gpios
*/
enum kim_gpio_state {
KIM_GPIO_INACTIVE,
KIM_GPIO_ACTIVE,
};
/**
* enum proto-type - The protocol on WiLink chips which share a
* common physical interface like UART.
*/
enum proto_type {
ST_BT,
ST_FM,
ST_GPS,
ST_MAX,
};
/**
* struct st_proto_s - Per Protocol structure from BT/FM/GPS to ST
* @type: type of the protocol being registered among the
* available proto_type(BT, FM, GPS the protocol which share TTY).
* @recv: the receiver callback pointing to a function in the
* protocol drivers called by the ST driver upon receiving
* relevant data.
* @match_packet: reserved for future use, to make ST more generic
* @reg_complete_cb: callback handler pointing to a function in protocol
* handler called by ST when the pending registrations are complete.
* The registrations are marked pending, in situations when fw
* download is in progress.
* @write: pointer to function in ST provided to protocol drivers from ST,
* to be made use when protocol drivers have data to send to TTY.
* @priv_data: privdate data holder for the protocol drivers, sent
* from the protocol drivers during registration, and sent back on
* reg_complete_cb and recv.
*/
struct st_proto_s {
enum proto_type type;
long (*recv) (void *, struct sk_buff *);
unsigned char (*match_packet) (const unsigned char *data);
void (*reg_complete_cb) (void *, char data);
long (*write) (struct sk_buff *skb);
void *priv_data;
};
extern long st_register(struct st_proto_s *);
extern long st_unregister(enum proto_type);
#endif /* ST_H */
......@@ -28,15 +28,7 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/hci.h>
#include "fm.h"
/*
* packet formats for fm and gps
* #include "gps.h"
*/
#include "st_core.h"
#include "st_kim.h"
#include "st_ll.h"
#include "st.h"
#include "ti_wilink_st.h"
/* strings to be used for rfkill entries and by
* ST Core to be used for sysfs debug entry
......
/*
* Shared Transport Core header file
*
* Copyright (C) 2009 Texas Instruments
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef ST_CORE_H
#define ST_CORE_H
#include <linux/skbuff.h>
#include "st.h"
/* states of protocol list */
#define ST_NOTEMPTY 1
#define ST_EMPTY 0
/*
* possible st_states
*/
#define ST_INITIALIZING 1
#define ST_REG_IN_PROGRESS 2
#define ST_REG_PENDING 3
#define ST_WAITING_FOR_RESP 4
/**
* struct st_data_s - ST core internal structure
* @st_state: different states of ST like initializing, registration
* in progress, this is mainly used to return relevant err codes
* when protocol drivers are registering. It is also used to track
* the recv function, as in during fw download only HCI events
* can occur , where as during other times other events CH8, CH9
* can occur.
* @tty: tty provided by the TTY core for line disciplines.
* @ldisc_ops: the procedures that this line discipline registers with TTY.
* @tx_skb: If for some reason the tty's write returns lesser bytes written
* then to maintain the rest of data to be written on next instance.
* This needs to be protected, hence the lock inside wakeup func.
* @tx_state: if the data is being written onto the TTY and protocol driver
* wants to send more, queue up data and mark that there is
* more data to send.
* @list: the list of protocols registered, only MAX can exist, one protocol
* can register only once.
* @rx_state: states to be maintained inside st's tty receive
* @rx_count: count to be maintained inside st's tty receieve
* @rx_skb: the skb where all data for a protocol gets accumulated,
* since tty might not call receive when a complete event packet
* is received, the states, count and the skb needs to be maintained.
* @txq: the list of skbs which needs to be sent onto the TTY.
* @tx_waitq: if the chip is not in AWAKE state, the skbs needs to be queued
* up in here, PM(WAKEUP_IND) data needs to be sent and then the skbs
* from waitq can be moved onto the txq.
* Needs locking too.
* @lock: the lock to protect skbs, queues, and ST states.
* @protos_registered: count of the protocols registered, also when 0 the
* chip enable gpio can be toggled, and when it changes to 1 the fw
* needs to be downloaded to initialize chip side ST.
* @ll_state: the various PM states the chip can be, the states are notified
* to us, when the chip sends relevant PM packets(SLEEP_IND, WAKE_IND).
* @kim_data: reference to the parent encapsulating structure.
*
*/
struct st_data_s {
unsigned long st_state;
struct tty_struct *tty;
struct tty_ldisc_ops *ldisc_ops;
struct sk_buff *tx_skb;
#define ST_TX_SENDING 1
#define ST_TX_WAKEUP 2
unsigned long tx_state;
struct st_proto_s *list[ST_MAX];
unsigned long rx_state;
unsigned long rx_count;
struct sk_buff *rx_skb;
struct sk_buff_head txq, tx_waitq;
spinlock_t lock;
unsigned char protos_registered;
unsigned long ll_state;
void *kim_data;
};
/**
* st_int_write -
* point this to tty->driver->write or tty->ops->write
* depending upon the kernel version
*/
int st_int_write(struct st_data_s*, const unsigned char*, int);
/**
* st_write -
* internal write function, passed onto protocol drivers
* via the write function ptr of protocol struct
*/
long st_write(struct sk_buff *);
/* function to be called from ST-LL */
void st_ll_send_frame(enum proto_type, struct sk_buff *);
/* internal wake up function */
void st_tx_wakeup(struct st_data_s *st_data);
/* init, exit entry funcs called from KIM */
int st_core_init(struct st_data_s **);
void st_core_exit(struct st_data_s *);
/* ask for reference from KIM */
void st_kim_ref(struct st_data_s **, int);
#define GPS_STUB_TEST
#ifdef GPS_STUB_TEST
int gps_chrdrv_stub_write(const unsigned char*, int);
void gps_chrdrv_stub_init(void);
#endif
#endif /*ST_CORE_H */
......@@ -28,15 +28,16 @@
#include <linux/gpio.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/sched.h>
#include <linux/rfkill.h>
#include "st_kim.h"
/* understand BT events for fw response */
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/hci.h>
#include "ti_wilink_st.h"
static int kim_probe(struct platform_device *pdev);
static int kim_remove(struct platform_device *pdev);
......
......@@ -19,7 +19,9 @@
*/
#define pr_fmt(fmt) "(stll) :" fmt
#include "st_ll.h"
#include <linux/skbuff.h>
#include <linux/module.h>
#include "ti_wilink_st.h"
/**********************************************************************/
/* internal functions */
......
/*
* Shared Transport Low Level (ST LL)
*
* Copyright (C) 2009 Texas Instruments
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef ST_LL_H
#define ST_LL_H
#include <linux/skbuff.h>
#include "st.h"
#include "st_core.h"
/* ST LL receiver states */
#define ST_W4_PACKET_TYPE 0
#define ST_BT_W4_EVENT_HDR 1
#define ST_BT_W4_ACL_HDR 2
#define ST_BT_W4_SCO_HDR 3
#define ST_BT_W4_DATA 4
#define ST_FM_W4_EVENT_HDR 5
#define ST_GPS_W4_EVENT_HDR 6
/* ST LL state machines */
#define ST_LL_ASLEEP 0
#define ST_LL_ASLEEP_TO_AWAKE 1
#define ST_LL_AWAKE 2
#define ST_LL_AWAKE_TO_ASLEEP 3
#define ST_LL_INVALID 4
/* different PM notifications coming from chip */
#define LL_SLEEP_IND 0x30
#define LL_SLEEP_ACK 0x31
#define LL_WAKE_UP_IND 0x32
#define LL_WAKE_UP_ACK 0x33
/* initialize and de-init ST LL */
long st_ll_init(struct st_data_s *);
long st_ll_deinit(struct st_data_s *);
/**
* enable/disable ST LL along with KIM start/stop
* called by ST Core
*/
void st_ll_enable(struct st_data_s *);
void st_ll_disable(struct st_data_s *);
/**
* various funcs used by ST core to set/get the various PM states
* of the chip.
*/
unsigned long st_ll_getstate(struct st_data_s *);
unsigned long st_ll_sleep_state(struct st_data_s *, unsigned char);
void st_ll_wakeup(struct st_data_s *);
#endif /* ST_LL_H */
/*
* Shared Transport Line discipline driver Core
* Init Manager Module header file
* Copyright (C) 2009 Texas Instruments
* Shared Transport Header file
* To be included by the protocol stack drivers for
* Texas Instruments BT,FM and GPS combo chip drivers
* and also serves the sub-modules of the shared transport driver.
*
* Copyright (C) 2009-2010 Texas Instruments
* Author: Pavan Savoy <pavan_savoy@ti.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
......@@ -18,14 +22,174 @@
*
*/
#ifndef ST_KIM_H
#define ST_KIM_H
#ifndef TI_WILINK_ST_H
#define TI_WILINK_ST_H
/* TODO:
* Move the following to tty.h upon acceptance
*/
#define N_TI_WL 22 /* Ldisc for TI's WL BT, FM, GPS combo chips */
#ifdef __KERNEL__
/**
* enum kim_gpio_state - Few protocols such as FM have ACTIVE LOW
* gpio states for their chip/core enable gpios
*/
enum kim_gpio_state {
KIM_GPIO_INACTIVE,
KIM_GPIO_ACTIVE,
};
/**
* enum proto-type - The protocol on WiLink chips which share a
* common physical interface like UART.
*/
enum proto_type {
ST_BT,
ST_FM,
ST_GPS,
ST_MAX,
};
/**
* struct st_proto_s - Per Protocol structure from BT/FM/GPS to ST
* @type: type of the protocol being registered among the
* available proto_type(BT, FM, GPS the protocol which share TTY).
* @recv: the receiver callback pointing to a function in the
* protocol drivers called by the ST driver upon receiving
* relevant data.
* @match_packet: reserved for future use, to make ST more generic
* @reg_complete_cb: callback handler pointing to a function in protocol
* handler called by ST when the pending registrations are complete.
* The registrations are marked pending, in situations when fw
* download is in progress.
* @write: pointer to function in ST provided to protocol drivers from ST,
* to be made use when protocol drivers have data to send to TTY.
* @priv_data: privdate data holder for the protocol drivers, sent
* from the protocol drivers during registration, and sent back on
* reg_complete_cb and recv.
*/
struct st_proto_s {
enum proto_type type;
long (*recv) (void *, struct sk_buff *);
unsigned char (*match_packet) (const unsigned char *data);
void (*reg_complete_cb) (void *, char data);
long (*write) (struct sk_buff *skb);
void *priv_data;
};
extern long st_register(struct st_proto_s *);
extern long st_unregister(enum proto_type);
/*
* header information used by st_core.c
*/
/* states of protocol list */
#define ST_NOTEMPTY 1
#define ST_EMPTY 0
/*
* possible st_states
*/
#define ST_INITIALIZING 1
#define ST_REG_IN_PROGRESS 2
#define ST_REG_PENDING 3
#define ST_WAITING_FOR_RESP 4
/**
* struct st_data_s - ST core internal structure
* @st_state: different states of ST like initializing, registration
* in progress, this is mainly used to return relevant err codes
* when protocol drivers are registering. It is also used to track
* the recv function, as in during fw download only HCI events
* can occur , where as during other times other events CH8, CH9
* can occur.
* @tty: tty provided by the TTY core for line disciplines.
* @ldisc_ops: the procedures that this line discipline registers with TTY.
* @tx_skb: If for some reason the tty's write returns lesser bytes written
* then to maintain the rest of data to be written on next instance.
* This needs to be protected, hence the lock inside wakeup func.
* @tx_state: if the data is being written onto the TTY and protocol driver
* wants to send more, queue up data and mark that there is
* more data to send.
* @list: the list of protocols registered, only MAX can exist, one protocol
* can register only once.
* @rx_state: states to be maintained inside st's tty receive
* @rx_count: count to be maintained inside st's tty receieve
* @rx_skb: the skb where all data for a protocol gets accumulated,
* since tty might not call receive when a complete event packet
* is received, the states, count and the skb needs to be maintained.
* @txq: the list of skbs which needs to be sent onto the TTY.
* @tx_waitq: if the chip is not in AWAKE state, the skbs needs to be queued
* up in here, PM(WAKEUP_IND) data needs to be sent and then the skbs
* from waitq can be moved onto the txq.
* Needs locking too.
* @lock: the lock to protect skbs, queues, and ST states.
* @protos_registered: count of the protocols registered, also when 0 the
* chip enable gpio can be toggled, and when it changes to 1 the fw
* needs to be downloaded to initialize chip side ST.
* @ll_state: the various PM states the chip can be, the states are notified
* to us, when the chip sends relevant PM packets(SLEEP_IND, WAKE_IND).
* @kim_data: reference to the parent encapsulating structure.
*
*/
struct st_data_s {
unsigned long st_state;
struct tty_struct *tty;
struct tty_ldisc_ops *ldisc_ops;
struct sk_buff *tx_skb;
#define ST_TX_SENDING 1
#define ST_TX_WAKEUP 2
unsigned long tx_state;
struct st_proto_s *list[ST_MAX];
unsigned long rx_state;
unsigned long rx_count;
struct sk_buff *rx_skb;
struct sk_buff_head txq, tx_waitq;
spinlock_t lock;
unsigned char protos_registered;
unsigned long ll_state;
void *kim_data;
};
/**
* st_int_write -
* point this to tty->driver->write or tty->ops->write
* depending upon the kernel version
*/
int st_int_write(struct st_data_s*, const unsigned char*, int);
/**
* st_write -
* internal write function, passed onto protocol drivers
* via the write function ptr of protocol struct
*/
long st_write(struct sk_buff *);
/* function to be called from ST-LL */
void st_ll_send_frame(enum proto_type, struct sk_buff *);
/* internal wake up function */
void st_tx_wakeup(struct st_data_s *st_data);
/* init, exit entry funcs called from KIM */
int st_core_init(struct st_data_s **);
void st_core_exit(struct st_data_s *);
/* ask for reference from KIM */
void st_kim_ref(struct st_data_s **, int);
#include <linux/types.h>
#include "st.h"
#include "st_core.h"
#include "st_ll.h"
#include <linux/rfkill.h>
#define GPS_STUB_TEST
#ifdef GPS_STUB_TEST
int gps_chrdrv_stub_write(const unsigned char*, int);
void gps_chrdrv_stub_init(void);
#endif
/*
* header information used by st_kim.c
*/
/* time in msec to wait for
* line discipline to be installed
......@@ -176,5 +340,70 @@ struct hci_command {
u32 speed;
} __attribute__ ((packed));
/*
* header information used by st_ll.c
*/
/* ST LL receiver states */
#define ST_W4_PACKET_TYPE 0
#define ST_BT_W4_EVENT_HDR 1
#define ST_BT_W4_ACL_HDR 2
#define ST_BT_W4_SCO_HDR 3
#define ST_BT_W4_DATA 4
#define ST_FM_W4_EVENT_HDR 5
#define ST_GPS_W4_EVENT_HDR 6
/* ST LL state machines */
#define ST_LL_ASLEEP 0
#define ST_LL_ASLEEP_TO_AWAKE 1
#define ST_LL_AWAKE 2
#define ST_LL_AWAKE_TO_ASLEEP 3
#define ST_LL_INVALID 4
/* different PM notifications coming from chip */
#define LL_SLEEP_IND 0x30
#define LL_SLEEP_ACK 0x31
#define LL_WAKE_UP_IND 0x32
#define LL_WAKE_UP_ACK 0x33
/* initialize and de-init ST LL */
long st_ll_init(struct st_data_s *);
long st_ll_deinit(struct st_data_s *);
/**
* enable/disable ST LL along with KIM start/stop
* called by ST Core
*/
void st_ll_enable(struct st_data_s *);
void st_ll_disable(struct st_data_s *);
/**
* various funcs used by ST core to set/get the various PM states
* of the chip.
*/
unsigned long st_ll_getstate(struct st_data_s *);
unsigned long st_ll_sleep_state(struct st_data_s *, unsigned char);
void st_ll_wakeup(struct st_data_s *);
/*
* header information used by st_core.c for FM and GPS
* packet parsing, the bluetooth headers are already available
* at net/bluetooth/
*/
struct fm_event_hdr {
u8 plen;
} __attribute__ ((packed));
#define FM_MAX_FRAME_SIZE 0xFF /* TODO: */
#define FM_EVENT_HDR_SIZE 1 /* size of fm_event_hdr */
#define ST_FM_CH8_PKT 0x8
/* gps stuff */
struct gps_event_hdr {
u8 opcode;
u16 plen;
} __attribute__ ((packed));
#endif /* ST_KIM_H */
#endif /* __KERNEL__ */
#endif /* TI_WILINK_ST_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment