sdio.c (50501936288d6a29d7ef78f25d00e33240fad45f) sdio.c (975e122ddb7cd6f67bff974d2ea00c5568d2014c)
1// SPDX-License-Identifier: ISC
2/* Copyright (C) 2021 MediaTek Inc.
3 *
4 */
5
6#include <linux/kernel.h>
7#include <linux/iopoll.h>
8#include <linux/module.h>

--- 13 unchanged lines hidden (view full) ---

22 { } /* Terminating entry */
23};
24
25static void mt7921s_txrx_worker(struct mt76_worker *w)
26{
27 struct mt76_sdio *sdio = container_of(w, struct mt76_sdio,
28 txrx_worker);
29 struct mt76_dev *mdev = container_of(sdio, struct mt76_dev, sdio);
1// SPDX-License-Identifier: ISC
2/* Copyright (C) 2021 MediaTek Inc.
3 *
4 */
5
6#include <linux/kernel.h>
7#include <linux/iopoll.h>
8#include <linux/module.h>

--- 13 unchanged lines hidden (view full) ---

22 { } /* Terminating entry */
23};
24
25static void mt7921s_txrx_worker(struct mt76_worker *w)
26{
27 struct mt76_sdio *sdio = container_of(w, struct mt76_sdio,
28 txrx_worker);
29 struct mt76_dev *mdev = container_of(sdio, struct mt76_dev, sdio);
30 struct mt7921_dev *dev = container_of(mdev, struct mt7921_dev, mt76);
30 struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev, mt76);
31
32 if (!mt76_connac_pm_ref(&dev->mphy, &dev->pm)) {
33 queue_work(mdev->wq, &dev->pm.wake_work);
34 return;
35 }
36
37 mt76s_txrx_worker(sdio);
38 mt76_connac_pm_unref(&dev->mphy, &dev->pm);
39}
40
31
32 if (!mt76_connac_pm_ref(&dev->mphy, &dev->pm)) {
33 queue_work(mdev->wq, &dev->pm.wake_work);
34 return;
35 }
36
37 mt76s_txrx_worker(sdio);
38 mt76_connac_pm_unref(&dev->mphy, &dev->pm);
39}
40
41static void mt7921s_unregister_device(struct mt7921_dev *dev)
41static void mt7921s_unregister_device(struct mt792x_dev *dev)
42{
43 struct mt76_connac_pm *pm = &dev->pm;
44
45 cancel_work_sync(&dev->init_work);
46 mt76_unregister_device(&dev->mt76);
47 cancel_delayed_work_sync(&pm->ps_work);
48 cancel_work_sync(&pm->wake_work);
49

--- 67 unchanged lines hidden (view full) ---

117 static const struct mt7921_hif_ops mt7921_sdio_ops = {
118 .init_reset = mt7921s_init_reset,
119 .reset = mt7921s_mac_reset,
120 .mcu_init = mt7921s_mcu_init,
121 .drv_own = mt7921s_mcu_drv_pmctrl,
122 .fw_own = mt7921s_mcu_fw_pmctrl,
123 };
124 struct ieee80211_ops *ops;
42{
43 struct mt76_connac_pm *pm = &dev->pm;
44
45 cancel_work_sync(&dev->init_work);
46 mt76_unregister_device(&dev->mt76);
47 cancel_delayed_work_sync(&pm->ps_work);
48 cancel_work_sync(&pm->wake_work);
49

--- 67 unchanged lines hidden (view full) ---

117 static const struct mt7921_hif_ops mt7921_sdio_ops = {
118 .init_reset = mt7921s_init_reset,
119 .reset = mt7921s_mac_reset,
120 .mcu_init = mt7921s_mcu_init,
121 .drv_own = mt7921s_mcu_drv_pmctrl,
122 .fw_own = mt7921s_mcu_fw_pmctrl,
123 };
124 struct ieee80211_ops *ops;
125 struct mt7921_dev *dev;
125 struct mt792x_dev *dev;
126 struct mt76_dev *mdev;
127 u8 features;
128 int ret;
129
130 ops = mt7921_get_mac80211_ops(&func->dev, (void *)id->driver_data,
131 &features);
132 if (!ops)
133 return -ENOMEM;
134
135 mdev = mt76_alloc_device(&func->dev, sizeof(*dev), ops, &drv_ops);
136 if (!mdev)
137 return -ENOMEM;
138
126 struct mt76_dev *mdev;
127 u8 features;
128 int ret;
129
130 ops = mt7921_get_mac80211_ops(&func->dev, (void *)id->driver_data,
131 &features);
132 if (!ops)
133 return -ENOMEM;
134
135 mdev = mt76_alloc_device(&func->dev, sizeof(*dev), ops, &drv_ops);
136 if (!mdev)
137 return -ENOMEM;
138
139 dev = container_of(mdev, struct mt7921_dev, mt76);
139 dev = container_of(mdev, struct mt792x_dev, mt76);
140 dev->fw_features = features;
141 dev->hif_ops = &mt7921_sdio_ops;
142 sdio_set_drvdata(func, dev);
143
144 ret = mt76s_init(mdev, func, &mt7921s_ops);
145 if (ret < 0)
146 goto error;
147

--- 43 unchanged lines hidden (view full) ---

191 mt76s_deinit(&dev->mt76);
192 mt76_free_device(&dev->mt76);
193
194 return ret;
195}
196
197static void mt7921s_remove(struct sdio_func *func)
198{
140 dev->fw_features = features;
141 dev->hif_ops = &mt7921_sdio_ops;
142 sdio_set_drvdata(func, dev);
143
144 ret = mt76s_init(mdev, func, &mt7921s_ops);
145 if (ret < 0)
146 goto error;
147

--- 43 unchanged lines hidden (view full) ---

191 mt76s_deinit(&dev->mt76);
192 mt76_free_device(&dev->mt76);
193
194 return ret;
195}
196
197static void mt7921s_remove(struct sdio_func *func)
198{
199 struct mt7921_dev *dev = sdio_get_drvdata(func);
199 struct mt792x_dev *dev = sdio_get_drvdata(func);
200
201 mt7921s_unregister_device(dev);
202}
203
204static int mt7921s_suspend(struct device *__dev)
205{
206 struct sdio_func *func = dev_to_sdio_func(__dev);
200
201 mt7921s_unregister_device(dev);
202}
203
204static int mt7921s_suspend(struct device *__dev)
205{
206 struct sdio_func *func = dev_to_sdio_func(__dev);
207 struct mt7921_dev *dev = sdio_get_drvdata(func);
207 struct mt792x_dev *dev = sdio_get_drvdata(func);
208 struct mt76_connac_pm *pm = &dev->pm;
209 struct mt76_dev *mdev = &dev->mt76;
210 int err;
211
212 pm->suspended = true;
213 set_bit(MT76_STATE_SUSPEND, &mdev->phy.state);
214
215 flush_work(&dev->reset_work);

--- 56 unchanged lines hidden (view full) ---

272 mt7921_reset(&dev->mt76);
273
274 return err;
275}
276
277static int mt7921s_resume(struct device *__dev)
278{
279 struct sdio_func *func = dev_to_sdio_func(__dev);
208 struct mt76_connac_pm *pm = &dev->pm;
209 struct mt76_dev *mdev = &dev->mt76;
210 int err;
211
212 pm->suspended = true;
213 set_bit(MT76_STATE_SUSPEND, &mdev->phy.state);
214
215 flush_work(&dev->reset_work);

--- 56 unchanged lines hidden (view full) ---

272 mt7921_reset(&dev->mt76);
273
274 return err;
275}
276
277static int mt7921s_resume(struct device *__dev)
278{
279 struct sdio_func *func = dev_to_sdio_func(__dev);
280 struct mt7921_dev *dev = sdio_get_drvdata(func);
280 struct mt792x_dev *dev = sdio_get_drvdata(func);
281 struct mt76_connac_pm *pm = &dev->pm;
282 struct mt76_dev *mdev = &dev->mt76;
283 int err;
284
285 clear_bit(MT76_STATE_SUSPEND, &mdev->phy.state);
286
287 err = mt7921_mcu_drv_pmctrl(dev);
288 if (err < 0)

--- 37 unchanged lines hidden ---
281 struct mt76_connac_pm *pm = &dev->pm;
282 struct mt76_dev *mdev = &dev->mt76;
283 int err;
284
285 clear_bit(MT76_STATE_SUSPEND, &mdev->phy.state);
286
287 err = mt7921_mcu_drv_pmctrl(dev);
288 if (err < 0)

--- 37 unchanged lines hidden ---