/* sfp_phy.h - Puma7 SoC SFP PHY Driver * * Copyright (C) 2016 Intel Corporation. All rights reserved. * * 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. * */ #ifndef __LINUX_SFP_PHY_H__ #define __LINUX_SFP_PHY_H__ #include #include #define PUMA_SFP_DEVICE_NAME "INT3518" #define PUMA_ACPI_NOTIFY_SFP_EVENT 0xA3 #define PUMA_SFP_CLASS "SFP" #define SFP_PRESENT 0 #define SFP_NOT_PRESENT 1 #define SFP_TX_ENABLE 0 #define SFP_POWER_ON 1 #define PROCESS_TXFAULT 1 #define PROCESS_LOS 1 #define PROCESS_PRESENT 1 #define PROCESS_ONAC 1 #define PROCESS_ONBAT 2 const char strs[5][15] = { "SFP_TxFault", "SFP_LOS", "SFP_PRESENT", "SFP_DISABLE", "SFP_POWER" }; enum sfp_acpi_pin_idx { TXFAULT_IDX, LOS_IDX, PRESENT_IDX, DISABLE_IDX, POWER_IDX, }; enum sfp_event_state { SFP_EVENT_AC, SFP_EVENT_ONBAT, SFP_STATE_OFF, SFP_STATE_ON, SFP_STATE_ACTIVE, }; /* New member to be added after looking at sfp_free_resources(). * The index order is important as it is used to free specific * resources. */ enum puma_resource_index { PUMA_SFP_MEM, PUMA_SFP_MUTEX, PUMA_SFP_SYSFS, PUMA_SFP_FREE_WQ, PUMA_SFP_TXFAULT_GPIO, PUMA_SFP_TXFAULT_IRQ, PUMA_SFP_LOS_GPIO, PUMA_SFP_LOS_IRQ, PUMA_SFP_PRESENT_GPIO, PUMA_SFP_PRESENT_IRQ, PUMA_SFP_TXDISABLE_GPIO, PUMA_SFP_POWER_GPIO, }; /** * struct puma7_sfp_phy - Puma7 SFP PHY device * @client: points to i2c slave SFP device * @handle: handle to the ACPI SFP device */ struct puma7_sfp_phy { struct i2c_client *client; acpi_handle handle; int txfault_irq; int los_irq; int present_irq; struct gpio_desc *gpio_txfault; struct gpio_desc *gpio_los; struct gpio_desc *gpio_present; struct gpio_desc *gpio_tx_disable; struct gpio_desc *gpio_power; unsigned int state; unsigned int txfault_counter; unsigned int los_counter; atomic_t service_level_value; struct workqueue_struct *work; struct work_struct cmd_work; atomic_t txfault_event; atomic_t los_event; atomic_t present_event; atomic_t servicelevel_event; struct mutex event_lock; }; #endif /* __LINUX_SFP_PHY_H__ */