159 lines
5.4 KiB
C
159 lines
5.4 KiB
C
/*
|
|
* Copyright (c) 202X Amlogic, Inc. All rights reserved.
|
|
*
|
|
* This source code is subject to the terms and conditions defined in the
|
|
* file 'LICENSE' which is part of this source code package.
|
|
*
|
|
* Description:
|
|
*/
|
|
|
|
#ifndef BT_HAL_PLATFORM_H
|
|
#define BT_HAL_PLATFORM_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <linux/mmc/sdio_func.h>
|
|
#include <linux/mmc/mmc.h>
|
|
#include <linux/mmc/host.h>
|
|
#include <linux/mmc/sdio.h>
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <linux/delay.h> /* udelay */
|
|
#include <linux/spinlock.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/etherdevice.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/version.h>
|
|
#include <linux/init.h>
|
|
#include <linux/device.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/moduleparam.h>
|
|
#include <linux/irqreturn.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/irq.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/kernel.h> /* printk() */
|
|
#include <linux/list.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/version.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/kthread.h>
|
|
#include <linux/gpio.h> //mach
|
|
#include <linux/timer.h>
|
|
#include <linux/string.h>
|
|
|
|
extern unsigned char w1_sdio_driver_insmoded;
|
|
extern unsigned char w1_sdio_after_porbe;
|
|
extern struct amlw1_hif_ops g_w1_hif_ops;
|
|
extern void amlwifi_set_sdio_host_clk(int clk);
|
|
extern void set_wifi_bt_sdio_driver_bit(bool is_register, int shift);
|
|
extern int aml_w1_sdio_init(void);
|
|
|
|
#define PRINT(...) do { printk("btHAL->"); printk(__VA_ARGS__); } while (0)
|
|
|
|
#if 1
|
|
#define CHIP_BT_PMU_REG_BASE (0xf03000)
|
|
#define RG_BT_PMU_A11 (CHIP_BT_PMU_REG_BASE + 0x2c)
|
|
#define RG_BT_PMU_A12 (CHIP_BT_PMU_REG_BASE + 0x30)
|
|
#define RG_BT_PMU_A13 (CHIP_BT_PMU_REG_BASE + 0x34)
|
|
#define RG_BT_PMU_A14 (CHIP_BT_PMU_REG_BASE + 0x38)
|
|
#define RG_BT_PMU_A15 (CHIP_BT_PMU_REG_BASE + 0x3c)
|
|
#define RG_BT_PMU_A16 (CHIP_BT_PMU_REG_BASE + 0x40)
|
|
#define RG_BT_PMU_A17 (CHIP_BT_PMU_REG_BASE + 0x44)
|
|
#define RG_BT_PMU_A18 (CHIP_BT_PMU_REG_BASE + 0x48)
|
|
#define RG_BT_PMU_A20 (CHIP_BT_PMU_REG_BASE + 0x50)
|
|
#define RG_BT_PMU_A22 (CHIP_BT_PMU_REG_BASE + 0x58)
|
|
|
|
#define CHIP_INTF_REG_BASE (0xf00000)
|
|
#define RG_AON_A15 (CHIP_INTF_REG_BASE + 0x3c)
|
|
#endif
|
|
|
|
#define SDIO_FUNC1 1
|
|
|
|
#define RG_BT_SDIO_PMU_HOST_REQ 0x231
|
|
#define RG_SDIO_PMU_STATUS 0x23c
|
|
|
|
// pmu status
|
|
#define PMU_PWR_OFF 0x0
|
|
#define PMU_PWR_XOSC 0x1
|
|
#define PMU_XOSC_WAIT 0x2
|
|
#define PMU_XOSC_DPLL 0x3
|
|
#define PMU_DPLL_WAIT 0x4
|
|
#define PMU_DPLL_ACT 0x5
|
|
#define PMU_ACT_MODE 0x6
|
|
#define PMU_ACT_SLEEP 0x7
|
|
#define PMU_SLEEP_MODE 0x8
|
|
#define PMU_SLEEP_WAKE 0x9
|
|
#define PMU_WAKE_WAIT 0xa
|
|
#define PMU_WAKE_XOSC 0xb
|
|
|
|
#define BT_BIT 0 //means bt
|
|
#define REGISTER_BT_SDIO 1 //used to mark register bt sdio ko
|
|
#define UNREGISTER_BT_SDIO 0
|
|
#define BT_PWR_ON 1
|
|
#define BT_PWR_OFF 0
|
|
|
|
typedef unsigned long SYS_TYPE;
|
|
|
|
enum {
|
|
AML_BT_EN = 0x1,
|
|
AML_SDIO_EN,
|
|
};
|
|
|
|
enum {
|
|
AML_SINGLE_ANTENNA = 0x1,
|
|
AML_DOUBLE_ANTENNA,
|
|
};
|
|
|
|
enum {
|
|
AML_W1 = 0x1,
|
|
AML_W1U,
|
|
};
|
|
|
|
|
|
struct amlw1_hif_ops {
|
|
int (*hi_bottom_write8)(unsigned char func_num, int addr, unsigned char data);
|
|
unsigned char (*hi_bottom_read8)(unsigned char func_num, int addr);
|
|
int (*hi_bottom_read)(unsigned char func_num, int addr, void *buf, size_t len, int incr_addr);
|
|
int (*hi_bottom_write)(unsigned char func_num, int addr, void *buf, size_t len, int incr_addr);
|
|
|
|
unsigned char (*hi_read8_func0)(unsigned long sram_addr);
|
|
void (*hi_write8_func0)(unsigned long sram_addr, unsigned char sramdata);
|
|
|
|
unsigned long (*hi_read_reg8)(unsigned long sram_addr);
|
|
void (*hi_write_reg8)(unsigned long sram_addr, unsigned long sramdata);
|
|
unsigned long (*hi_read_reg32)(unsigned long sram_addr);
|
|
int (*hi_write_reg32)(unsigned long sram_addr, unsigned long sramdata);
|
|
|
|
void (*hi_write_cmd)(unsigned long sram_addr, unsigned long sramdata);
|
|
void (*hi_write_sram)(unsigned char *buf, unsigned char *addr, SYS_TYPE len);
|
|
void (*hi_read_sram)(unsigned char *buf, unsigned char *addr, SYS_TYPE len);
|
|
void (*hi_write_word)(unsigned int addr, unsigned int data);
|
|
unsigned int (*hi_read_word)(unsigned int addr);
|
|
|
|
void (*hi_rcv_frame)(unsigned char *buf, unsigned char *addr, SYS_TYPE len);
|
|
|
|
int (*hi_enable_scat)(void);
|
|
void (*hi_cleanup_scat)(void);
|
|
struct amlw_hif_scatter_req * (*hi_get_scatreq)(void);
|
|
int (*hi_scat_rw)(struct scatterlist *sg_list, unsigned int sg_num, unsigned int blkcnt, unsigned char func_num, unsigned int addr, unsigned char write);
|
|
int (*hi_send_frame)(struct amlw_hif_scatter_req *scat_req);
|
|
|
|
/*bt use*/
|
|
void (*bt_hi_write_sram)(unsigned char *buf, unsigned char *addr, SYS_TYPE len);
|
|
void (*bt_hi_read_sram)(unsigned char *buf, unsigned char *addr, SYS_TYPE len);
|
|
void (*bt_hi_write_word)(unsigned int addr, unsigned int data);
|
|
unsigned int (*bt_hi_read_word)(unsigned int addr);
|
|
|
|
void (*hif_get_sts)(unsigned int op_code, unsigned int ctrl_code);
|
|
void (*hif_pt_rx_start)(unsigned int qos);
|
|
void (*hif_pt_rx_stop)(void);
|
|
|
|
int (*hif_suspend)(unsigned int suspend_enable);
|
|
};
|
|
|
|
#endif /* BT_HAL_PLATFORM_H */
|
|
|