linux/drivers/net/wwan/t7xx/t7xx_pci.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2021, MediaTek Inc.
 * Copyright (c) 2021-2022, Intel Corporation.
 *
 * Authors:
 *  Haijun Liu <[email protected]>
 *  Ricardo Martinez <[email protected]>
 *  Sreehari Kancharla <[email protected]>
 *
 * Contributors:
 *  Amir Hanania <[email protected]>
 *  Andy Shevchenko <[email protected]>
 *  Chiranjeevi Rapolu <[email protected]>
 *  Eliot Lee <[email protected]>
 *  Moises Veleta <[email protected]>
 */

#include <linux/atomic.h>
#include <linux/bits.h>
#include <linux/completion.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/gfp.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/jiffies.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pci.h>
#include <linux/pm.h>
#include <linux/pm_runtime.h>
#include <linux/pm_wakeup.h>
#include <linux/spinlock.h>

#include "t7xx_mhccif.h"
#include "t7xx_modem_ops.h"
#include "t7xx_pci.h"
#include "t7xx_pcie_mac.h"
#include "t7xx_reg.h"
#include "t7xx_state_monitor.h"

#define T7XX_PCI_IREG_BASE
#define T7XX_PCI_EREG_BASE

#define T7XX_INIT_TIMEOUT
#define PM_SLEEP_DIS_TIMEOUT_MS
#define PM_ACK_TIMEOUT_MS
#define PM_AUTOSUSPEND_MS
#define PM_RESOURCE_POLL_TIMEOUT_US
#define PM_RESOURCE_POLL_STEP_US

static const char * const t7xx_mode_names[] =;

static_assert();

static ssize_t t7xx_mode_store(struct device *dev,
			       struct device_attribute *attr,
			       const char *buf, size_t count)
{
	struct t7xx_pci_dev *t7xx_dev;
	struct pci_dev *pdev;
	enum t7xx_mode mode;
	int index = 0;

	pdev = to_pci_dev(dev);
	t7xx_dev = pci_get_drvdata(pdev);
	if (!t7xx_dev)
		return -ENODEV;

	mode = READ_ONCE(t7xx_dev->mode);

	index = sysfs_match_string(t7xx_mode_names, buf);
	if (index == mode)
		return -EBUSY;

	if (index == T7XX_FASTBOOT_SWITCHING) {
		if (mode == T7XX_FASTBOOT_DOWNLOAD)
			return count;

		WRITE_ONCE(t7xx_dev->mode, T7XX_FASTBOOT_SWITCHING);
		pm_runtime_resume(dev);
		t7xx_reset_device(t7xx_dev, FASTBOOT);
	} else if (index == T7XX_RESET) {
		pm_runtime_resume(dev);
		t7xx_reset_device(t7xx_dev, PLDR);
	}

	return count;
};

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

static DEVICE_ATTR_RW(t7xx_mode);

static struct attribute *t7xx_mode_attr[] =;

static const struct attribute_group t7xx_mode_attribute_group =;

void t7xx_mode_update(struct t7xx_pci_dev *t7xx_dev, enum t7xx_mode mode)
{}

enum t7xx_pm_state {};

static void t7xx_dev_set_sleep_capability(struct t7xx_pci_dev *t7xx_dev, bool enable)
{}

static int t7xx_wait_pm_config(struct t7xx_pci_dev *t7xx_dev)
{}

static int t7xx_pci_pm_init(struct t7xx_pci_dev *t7xx_dev)
{}

void t7xx_pci_pm_init_late(struct t7xx_pci_dev *t7xx_dev)
{}

static int t7xx_pci_pm_reinit(struct t7xx_pci_dev *t7xx_dev)
{}

void t7xx_pci_pm_exp_detected(struct t7xx_pci_dev *t7xx_dev)
{}

int t7xx_pci_pm_entity_register(struct t7xx_pci_dev *t7xx_dev, struct md_pm_entity *pm_entity)
{}

int t7xx_pci_pm_entity_unregister(struct t7xx_pci_dev *t7xx_dev, struct md_pm_entity *pm_entity)
{}

int t7xx_pci_sleep_disable_complete(struct t7xx_pci_dev *t7xx_dev)
{}

/**
 * t7xx_pci_disable_sleep() - Disable deep sleep capability.
 * @t7xx_dev: MTK device.
 *
 * Lock the deep sleep capability, note that the device can still go into deep sleep
 * state while device is in D0 state, from the host's point-of-view.
 *
 * If device is in deep sleep state, wake up the device and disable deep sleep capability.
 */
void t7xx_pci_disable_sleep(struct t7xx_pci_dev *t7xx_dev)
{}

/**
 * t7xx_pci_enable_sleep() - Enable deep sleep capability.
 * @t7xx_dev: MTK device.
 *
 * After enabling deep sleep, device can enter into deep sleep state.
 */
void t7xx_pci_enable_sleep(struct t7xx_pci_dev *t7xx_dev)
{}

static int t7xx_send_pm_request(struct t7xx_pci_dev *t7xx_dev, u32 request)
{}

static int __t7xx_pci_pm_suspend(struct pci_dev *pdev)
{}

static void t7xx_pcie_interrupt_reinit(struct t7xx_pci_dev *t7xx_dev)
{}

static int t7xx_pcie_reinit(struct t7xx_pci_dev *t7xx_dev, bool is_d3)
{}

static int t7xx_send_fsm_command(struct t7xx_pci_dev *t7xx_dev, u32 event)
{}

int t7xx_pci_reprobe_early(struct t7xx_pci_dev *t7xx_dev)
{}

int t7xx_pci_reprobe(struct t7xx_pci_dev *t7xx_dev, bool boot)
{}

static int __t7xx_pci_pm_resume(struct pci_dev *pdev, bool state_check)
{}

static int t7xx_pci_pm_resume_noirq(struct device *dev)
{}

static void t7xx_pci_shutdown(struct pci_dev *pdev)
{}

static int t7xx_pci_pm_prepare(struct device *dev)
{}

static int t7xx_pci_pm_suspend(struct device *dev)
{}

static int t7xx_pci_pm_resume(struct device *dev)
{}

static int t7xx_pci_pm_thaw(struct device *dev)
{}

static int t7xx_pci_pm_runtime_suspend(struct device *dev)
{}

static int t7xx_pci_pm_runtime_resume(struct device *dev)
{}

static const struct dev_pm_ops t7xx_pci_pm_ops =;

static int t7xx_request_irq(struct pci_dev *pdev)
{}

static int t7xx_setup_msix(struct t7xx_pci_dev *t7xx_dev)
{}

static int t7xx_interrupt_init(struct t7xx_pci_dev *t7xx_dev)
{}

static void t7xx_pci_infracfg_ao_calc(struct t7xx_pci_dev *t7xx_dev)
{}

static int t7xx_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{}

static void t7xx_pci_remove(struct pci_dev *pdev)
{}

static const struct pci_device_id t7xx_pci_table[] =;
MODULE_DEVICE_TABLE(pci, t7xx_pci_table);

static struct pci_driver t7xx_pci_driver =;

module_pci_driver();

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