summaryrefslogtreecommitdiffstats
path: root/firmware/WHENCE
blob: 34b5d0a036db7856389e8a92f8ff5cd08450f16b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
**********
             * WHENCE *
             **********

This file attempts to document the origin and licensing information,
if known, for each piece of firmware distributed for use with the Linux
kernel.

--------------------------------------------------------------------------

Driver: ambassador -- Madge Ambassador (Collage PCI 155 Server) ATM NIC.

File: firmware/atmsar11.fw

Licence: Allegedly GPLv2+, but no source visible. Marked:

  Madge Ambassador ATM Adapter microcode.
  Copyright (C) 1995-1999  Madge Networks Ltd.

  This microcode data is placed under the terms of the GNU General
  Public License. The GPL is contained in /usr/doc/copyright/GPL on a
  Debian system and in the file COPYING in the Linux kernel source.

  We would prefer you not to distribute modified versions without
  consultation and not to ask for assembly/other microcode source.

--------------------------------------------------------------------------

Driver: korg1212 -- Korg 1212 IO audio device

File: korg/k1212.dsp

Licence: Unknown

Found in alsa-firmware package in hex form; no licensing information.

--------------------------------------------------------------------------

Driver: maestro3 -- ESS Allegro Maestro3 audio device

File: ess/maestro3_assp_kernel.fw
File: ess/maestro3_assp_minisrc.fw

Licence: Unknown

Found in alsa-firmware package in hex form with a comment claiming to
be GPLv2+, but without source -- and with another comment saying "ESS
drops binary dsp code images on our heads, but we don't get to see
specs on the dsp."

--------------------------------------------------------------------------

Driver: ymfpci -- Yamaha YMF724/740/744/754 audio devices

File: yamaha/ds1_ctrl.fw
File: yamaha/ds1_dsp.fw
File: yamaha/ds1e_ctrl.fw

Licence: Unknown

Found alsa-firmware package in hex form, with the following comment:
   Copyright (c) 1997-1999 Yamaha Corporation. All Rights Reserved.

--------------------------------------------------------------------------

Driver: SCSI_ADVANSYS - AdvanSys SCSI

File: advansys/mcode.bin
File: advansys/3550.bin
File: advansys/38C0800.bin
File: advansys/38C1600.bin

Licence: BSD, no source available.

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: SCSI_QLOGIC_1280 - Qlogic QLA 1240/1x80/1x160 SCSI support

File: qlogic/1040.bin
File: qlogic/1280.bin
File: qlogic/12160.bin

Licence: Allegedly GPLv2+, but no source visible. Marked:

                   QLOGIC LINUX SOFTWARE
  QLogic ISP1280/ device driver for Linux 2.2.x and 2.4.x
  Copyright (C) 2001 Qlogic Corporation (www.qlogic.com)

--------------------------------------------------------------------------
Driver: smctr -- SMC ISA/MCA Token Ring adapter

File: tr_smctr.bin
Info: MCT.BIN v6.3C1 03/01/95

Original licence info:

 * This firmware is licensed to you strictly for use in conjunction
 * with the use of SMC TokenRing adapters. There is no waranty
 * expressed or implied about its fitness for any purpose.

--------------------------------------------------------------------------

Driver: kaweth -- USB KLSI KL5USB101-based Ethernet device

File: kaweth/new_code.bin
File: kaweth/new_code_fix.bin
File: kaweth/trigger_code.bin
File: kaweth/trigger_code_fix.bin

Licence: Unknown

Found in hex form in the kernel source.

--------------------------------------------------------------------------

Driver: ttusb-budget -- Technotrend/Hauppauge Nova-USB devices

File: ttusb-budget/dspbootcode.bin

Licence: Unknown

Found in hex form in the kernel source.

--------------------------------------------------------------------------

Driver: keyspan -- USB Keyspan USA-xxx serial device

File: keyspan/mpr.fw
File: keyspan/usa18x.fw
File: keyspan/usa19.fw
File: keyspan/usa19qi.fw
File: keyspan/usa19qw.fw
File: keyspan/usa19w.fw
File: keyspan/usa28.fw
File: keyspan/usa28xa.fw
File: keyspan/usa28xb.fw
File: keyspan/usa28x.fw
File: keyspan/usa49w.fw
File: keyspan/usa49wlc.fw

Converted from Intel HEX files, used in our binary representation of ihex.

Original licence information:

		Copyright (C) 1999-2001
		Keyspan, A division of InnoSys Incorporated ("Keyspan")

	as an unpublished work. This notice does not imply unrestricted or
	public access to the source code from which this firmware image is
	derived.  Except as noted below this firmware image may not be
	reproduced, used, sold or transferred to any third party without
	Keyspan's prior written consent.  All Rights Reserved.

	Permission is hereby granted for the distribution of this firmware
	image as part of a Linux or other Open Source operating system kernel
	in text or binary form as required.

	This firmware may not be modified and may only be used with
	Keyspan hardware.  Distribution and/or Modification of the
	keyspan.c driver which includes this firmware, in whole or in
	part, requires the inclusion of this statement."

--------------------------------------------------------------------------

Driver: keyspan_pda -- USB Keyspan PDA single-port serial device

File: keyspan_pda/keyspan_pda.fw
Source: keyspan_pda/keyspan_pda.S

File: keyspan_pda/xircom_pgs.fw
Source: keyspan_pda/xircom_pgs.S

Licence: GPLv2+

Compiled from original 8051 source into Intel HEX, used in our binary ihex form.

--------------------------------------------------------------------------

Driver: emi26 -- EMI 2|6 USB Audio interface

File: emi26/bitstream.fw
Info: VERSION=1.1.1.131 DATE=2001dec06

File: emi26/firmware.fw
Info: VERSION=1.0.2.916 DATE=12.02.2002

File: emi26/loader.fw

Converted from Intel HEX files, used in our binary representation of ihex.

Original licence information:
/*
 * This firmware is for the Emagic EMI 2|6 Audio Interface
 *
 * The firmware contained herein is Copyright (c) 1999-2002 Emagic
 * as an unpublished work. This notice does not imply unrestricted
 * or public access to this firmware which is a trade secret of Emagic,
 * and which may not be reproduced, used, sold or transferred to
 * any third party without Emagic's written consent. All Rights Reserved.
 *
 * Permission is hereby granted for the distribution of this firmware
 * image as part of a Linux or other Open Source operating system kernel
 * in text or binary form as required.
 *
 * This firmware may not be modified and may only be used with the
 * Emagic EMI 2|6 Audio Interface. Distribution and/or Modification of
 * any driver which includes this firmware, in whole or in part,
 * requires the inclusion of this statement.
 */

--------------------------------------------------------------------------

Driver: emi62 -- EMI 6|2m USB Audio interface

File: emi62/bitstream.fw
Info: VERSION=1.0.0.191 DATE= 2002oct28

File: emi62/loader.fw
Source: EMILOAD.HEX
Info: VERSION=1.0.2.002 DATE=10.01.2002

File: emi62/midi.fw
Source: EMI62MFW.HEX
Info: VERSION=1.04.062 DATE=16.10.2002

File: emi62/spdif.fw
Source: EMI62SFW.HEX
Info: VERSION=1.04.062 DATE=16.10.2002

Converted from Intel HEX files, used in our binary representation of ihex.

Original licence information: None

--------------------------------------------------------------------------

Driver: ti_usb_3410_5052 -- USB TI 3410/5052 serial device

File: ti_3410.fw
Info: firmware 9/10/04 FW3410_Special_StartWdogOnStartPort

File: ti_5052.fw
Info: firmware 9/18/04

Licence: Allegedly GPLv2+, but no source visible. Marked:
	 Copyright (C) 2004 Texas Instruments

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: ti_usb_3410_5052 -- Multi-Tech USB cell modems

File: mts_cdma.fw
File: mts_gsm.fw
File: mts_edge.fw

Licence: "all firmware components are redistributable in binary form"
         per support@multitech.com
	 Copyright (C) 2005 Multi-Tech Systems, Inc.

Found in hex form in ftp://ftp.multitech.com/wireless/wireless_linux.zip

--------------------------------------------------------------------------

Driver: whiteheat -- USB ConnectTech WhiteHEAT serial device

File: whiteheat.fw
Version: 4.06

File: whiteheat_loader.fw
File: whiteheat_loader_debug.fw

Licence: Allegedly GPLv2, but no source visible. Marked:
	 Copyright (C) 2000-2002  ConnectTech Inc

Debug loader claims the following behaviour:
	Port 1 LED flashes when the vend_ax program is running
	Port 2 LED flashes when any SETUP command arrives
	Port 3 LED flashes when any valid VENDOR request occurs
	Port 4 LED flashes when the EXTERNAL RAM DOWNLOAD request occurs

Converted from Intel HEX files, used in our binary representation of ihex.

--------------------------------------------------------------------------

Driver: ip2 -- Computone IntelliPort Plus serial device

File: intelliport2.bin

Licence: Unknown

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: CPiA2 -- cameras based on Vision's CPiA2

File: cpia2/stv0672_vp4.bin

Licence: Allegedly GPLv2+, but no source visible. Marked:
	Copyright (C) 2001 STMicroelectronics, Inc.
	Contact:  steve.miller@st.com
	Description: This file contains patch data for the CPiA2 (stv0672) VP4.

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: DABUSB -- Digital Audio Broadcasting (DAB) Receiver for USB and Linux

File: dabusb/firmware.fw
File: dabusb/bitstream.bin

Licence: Distributable

 * Copyright (C) 1999 BayCom GmbH
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that redistributions of source
 * code retain the above copyright notice and this comment without
 * modification.

--------------------------------------------------------------------------

Driver: USB_VICAM -- USB 3com HomeConnect (aka vicam)

File: vicam/firmware.fw

Licence: Unknown

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: USB_SERIAL_EDGEPORT - USB Inside Out Edgeport Serial Driver

File: edgeport/boot.fw
File: edgeport/boot2.fw
File: edgeport/down.fw
File: edgeport/down2.fw

Licence: Allegedly GPLv2+, but no source visible. Marked:
//**************************************************************
//* Edgeport/4 Binary Image
//* Generated by HEX2C v1.06
//* Copyright (C) 1998 Inside Out Networks, All rights reserved.
//**************************************************************

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: USB_SERIAL_EDGEPORT_TI - USB Inside Out Edgeport Serial Driver
(TI Devices)

File: edgeport/down3.bin

Licence:
//**************************************************************
//* Edgeport Binary Image (for TI based products)
//* Generated by TIBin2C v2.00 (watchport)
//* Copyright (C) 2001 Inside Out Networks, All rights reserved.
//**************************************************************

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: ATARI_DSP56K - Atari DSP56k support

File: dsp56k/bootstrap.bin
Source: dsp56k/bootstrap.asm

Licence: GPLv2 or later

DSP56001 assembler, possibly buildable with a56 from 
http://www.zdomain.com/a56.html

--------------------------------------------------------------------------

Driver: SND_SB16_CSP - Sound Blaster 16/AWE CSP support

File: sb16/mulaw_main.csp
File: sb16/alaw_main.csp
File: sb16/ima_adpcm_init.csp
File: sb16/ima_adpcm_playback.csp
File: sb16/ima_adpcm_capture.csp

Licence: Allegedly GPLv2+, but no source visible. Marked:
/*
 *  Copyright (c) 1994 Creative Technology Ltd.
 *  Microcode files for SB16 Advanced Signal Processor
 */

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: CASSINI - Sun Cassini

File: sun/cassini.bin

Licence: Unknown

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: cxgb3 - Chelsio Terminator 3 1G/10G Ethernet adapter

File: cxgb3/t3b_psram-1.1.0.bin.ihex
File: cxgb3/t3c_psram-1.1.0.bin.ihex
file: cxgb3/t3fw-7.4.0.bin.ihex

License: GPLv2 or OpenIB.org BSD license, no source visible

--------------------------------------------------------------------------

Driver: cxgb3 - Chelsio Terminator 3 1G/10G Ethernet adapter

File: cxgb3/ael2005_opt_edc.bin.ihex
File: cxgb3/ael2005_twx_edc.bin.ihex
File: cxgb3/ael2020_twx_edc.bin.ihex

Licence:
 *	Copyright (c) 2007-2009 NetLogic Microsystems, Inc.
 *
 *	Permission is hereby granted for the distribution of this firmware
 *	data in hexadecimal or equivalent format, provided this copyright
 *	notice is accompanying it.

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: e100 -- Intel PRO/100 Ethernet NIC

File: e100/d101m_ucode.bin
File: e100/d101s_ucode.bin
File: e100/d102e_ucode.bin

Licence: Unknown

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: acenic -- Alteon AceNIC Gigabit Ethernet card

File: acenic/tg1.bin
File: acenic/tg2.bin

Licence: Unknown

Found in hex form in kernel source, but source allegedly available at
http://alteon.shareable.org/

--------------------------------------------------------------------------

Driver: tigon3 -- Broadcom Tigon3 based gigabit Ethernet cards

File: tigon/tg3.bin
File: tigon/tg3_tso.bin
File: tigon/tg3_tso5.bin

Licence:
 * Firmware is:
 *	Derived from proprietary unpublished source code,
 *	Copyright (C) 2000-2003 Broadcom Corporation.
 *
 *	Permission is hereby granted for the distribution of this firmware
 *	data in hexadecimal or equivalent format, provided this copyright
 *	notice is accompanying it.

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: ADAPTEC_STARFIRE - Adaptec Starfire/DuraLAN support

File: adaptec/starfire_rx.bin
File: adaptec/starfire_tx.bin

Licence: Allegedly GPLv2, but no source visible.

Found in hex form in kernel source, with the following notice:

 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE IT IS LICENSED "AS IS" AND
 THERE IS NO WARRANTY FOR THE PROGRAM, INCLUDING BUT NOT LIMITED TO THE
 IMPLIED WARRANTIES OF MERCHANTIBILITY OR FITNESS FOR A PARTICULAR PURPOSE
 (TO THE EXTENT PERMITTED BY APPLICABLE LAW). USE OF THE PROGRAM IS AT YOUR
 OWN RISK. IN NO EVENT WILL ADAPTEC OR ITS LICENSORS BE LIABLE TO YOU FOR
 DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
 ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM.

--------------------------------------------------------------------------

Driver: TEHUTI - Tehuti Networks 10G Ethernet

File: tehuti/bdx.bin

Licence:

 Copyright (C) 2007 Tehuti Networks Ltd.

 Permission is hereby granted for the distribution of this firmware data
 in hexadecimal or equivalent format, provided this copyright notice is
 accompanying it.

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: TYPHOON - 3cr990 series Typhoon

File: 3com/typhoon.bin

Licence:
/*
 * Copyright 1999-2004 3Com Corporation.  All Rights Reserved.
 *
 * Redistribution and use in source and binary forms of the 3c990img.h
 * microcode software are permitted provided that the following conditions
 * are met:
 * 1. Redistribution of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistribution in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The name of 3Com may not be used to endorse or promote products
 *    derived from this software without specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY 3COM ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * USER ACKNOWLEDGES AND AGREES THAT PURCHASE OR USE OF THE 3c990img.h
 * MICROCODE SOFTWARE WILL NOT CREATE OR GIVE GROUNDS FOR A LICENSE BY
 * IMPLICATION, ESTOPPEL, OR OTHERWISE IN ANY INTELLECTUAL PROPERTY RIGHTS
 * (PATENT, COPYRIGHT, TRADE SECRET, MASK WORK, OR OTHER PROPRIETARY RIGHT)
 * EMBODIED IN ANY OTHER 3COM HARDWARE OR SOFTWARE EITHER SOLELY OR IN
 * COMBINATION WITH THE 3c990img.h MICROCODE SOFTWARE
 */

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: YAM - YAM driver for AX.25

File: yam/1200.bin
File: yam/9600.bin

Licence:
 * (C) F6FBB 1998

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: 3C359 - 3Com 3C359 Token Link Velocity XL adapter

File: 3com/3C359.bin

Licence:
/*
 * The firmware this driver downloads into the tokenring card is a
 * separate program and is not GPL'd source code, even though the Linux
 * side driver and the routine that loads this data into the card are.
 *
 * This firmware is licensed to you strictly for use in conjunction
 * with the use of 3Com 3C359 TokenRing adapters. There is no
 * waranty expressed or implied about its fitness for any purpose.
 */
/* 3c359_microcode.mac: 3Com 3C359 Tokenring microcode.
 *
 * Notes:
 *  - Loaded from xl_init upon adapter initialization.
 *
 * Available from 3Com as part of their standard 3C359 driver.
 */

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: PCMCIA_PCNET - NE2000 compatible PCMCIA adapter

File: cis/LA-PCM.cis
      cis/PCMLM28.cis
      cis/DP83903.cis
      cis/NE2K.cis
      cis/tamarack.cis
      cis/PE-200.cis

Licence: GPL

Originally developed by the pcmcia-cs project

--------------------------------------------------------------------------

Driver: PCMCIA_3C589 - 3Com PCMCIA adapter

File: cis/3CXEM556.cis

Licence: GPL

Originally developed by the pcmcia-cs project

--------------------------------------------------------------------------

Driver: PCMCIA_3C574 - 3Com PCMCIA adapter

File: cis/3CCFEM556.cis

Licence: GPL

Originally developed by the pcmcia-cs project

--------------------------------------------------------------------------

Driver: SERIAL_8250_CS - Serial PCMCIA adapter

File: cis/MT5634ZLX.cis
      cis/RS-COM-2P.cis
      cis/COMpad2.cis
      cis/COMpad4.cis
      cis/SW_555_SER.cis
      cis/SW_7xx_SER.cis
      cis/SW_8xx_SER.cis

Licence: GPL

Originally developed by the pcmcia-cs project

--------------------------------------------------------------------------

Driver: PCMCIA_SMC91C92 - SMC 91Cxx PCMCIA

File: ositech/Xilinx7OD.bin

Licence: Allegedly GPL, but no source visible. Marked:
    This file contains the firmware of Seven of Diamonds from OSITECH.
    (Special thanks to Kevin MacPherson of OSITECH)

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: SCSI_QLOGICPTI - PTI Qlogic, ISP Driver

File: qlogic/isp1000.bin

Licence: Unknown

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: MYRI_SBUS - MyriCOM Gigabit Ethernet

File: myricom/lanai.bin

Licence: Unknown

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: bnx2x: Broadcom Everest

File: bnx2x-e1-5.2.7.0.fw.ihex
File: bnx2x-e1h-5.2.7.0.fw.ihex

License:
  Copyright (c) 2007-2009 Broadcom Corporation

  This file contains firmware data derived from proprietary unpublished
  source code, Copyright (c) 2007-2009 Broadcom Corporation.

  Permission is hereby granted for the distribution of this firmware data
  in hexadecimal or equivalent format, provided this copyright notice is
  accompanying it.


Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: BNX2 - Broadcom NetXtremeII

File: bnx2/bnx2-mips-06-4.6.16.fw
File: bnx2/bnx2-rv2p-06-4.6.16.fw
File: bnx2/bnx2-mips-09-4.6.17.fw
File: bnx2/bnx2-rv2p-09-4.6.15.fw

Licence:

 This file contains firmware data derived from proprietary unpublished
 source code, Copyright (c) 2004 - 2009 Broadcom Corporation.

 Permission is hereby granted for the distribution of this firmware data
 in hexadecimal or equivalent format, provided this copyright notice is
 accompanying it.

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: DVB AV7110 -- AV7110 cards

File: av7110/bootcode.bin

Licence: GPLv2 or later

ARM assembly source code available at http://www.linuxtv.org/downloads/firmware/Boot.S

--------------------------------------------------------------------------

Driver: wavefront - ISA WaveFront sound card

File: yamaha/yss225_registers.bin

Licence: Allegedly GPLv2+, but no source visible.

Found in hex form in kernel source, with the following comment:
   Copyright (c) 1998-2002 by Paul Davis <pbd@op.net>

--------------------------------------------------------------------------

Driver: mga - Matrox G200/G400/G550

File: matrox/g200_warp.fw
File: matrox/g400_warp.fw

Licence:

Copyright 1999 Matrox Graphics Inc.
All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
MATROX GRAPHICS INC., OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Found in hex form in kernel source.

--------------------------------------------------------------------------

Driver: r128 - ATI Rage 128

File: r128/r128_cce.bin

Licence:

Copyright 2000 Advanced Micro Devices, Inc.

 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.

Found in decimal form in kernel source.

--------------------------------------------------------------------------

Driver: radeon - ATI Radeon

File: radeon/R100_cp.bin
File: radeon/R200_cp.bin
File: radeon/R300_cp.bin
File: radeon/R420_cp.bin
File: radeon/RS600_cp.bin
File: radeon/RS690_cp.bin
File: radeon/R520_cp.bin
File: radeon/R600_pfp.bin
File: radeon/R600_me.bin
File: radeon/RV610_pfp.bin
File: radeon/RV610_me.bin
File: radeon/RV630_pfp.bin
File: radeon/RV630_me.bin
File: radeon/RV620_pfp.bin
File: radeon/RV620_me.bin
File: radeon/RV635_pfp.bin
File: radeon/RV635_me.bin
File: radeon/RV670_pfp.bin
File: radeon/RV670_me.bin
File: radeon/RS780_pfp.bin
File: radeon/RS780_me.bin
File: radeon/RV770_pfp.bin
File: radeon/RV770_me.bin
File: radeon/RV730_pfp.bin
File: radeon/RV730_me.bin
File: radeon/RV710_pfp.bin
File: radeon/RV710_me.bin

Licence:

 * Copyright 2007-2009 Advanced Micro Devices, Inc.
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Found in hex form in kernel source.

--------------------------------------------------------------------------
'#n1585'>1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819
/*
 * Copyright 2016-2017 Google, Inc
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * 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.
 *
 * Fairchild FUSB302 Type-C Chip Driver
 */

#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of_device.h>
#include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <linux/pinctrl/consumer.h>
#include <linux/proc_fs.h>
#include <linux/regulator/consumer.h>
#include <linux/sched/clock.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/usb/typec.h>
#include <linux/workqueue.h>

#include "fusb302_reg.h"
#include "../tcpm.h"
#include "../pd.h"

/*
 * When the device is SNK, BC_LVL interrupt is used to monitor cc pins
 * for the current capability offered by the SRC. As FUSB302 chip fires
 * the BC_LVL interrupt on PD signalings, cc lvl should be handled after
 * a delay to avoid measuring on PD activities. The delay is slightly
 * longer than PD_T_PD_DEBPUNCE (10-20ms).
 */
#define T_BC_LVL_DEBOUNCE_DELAY_MS 30

enum toggling_mode {
	TOGGLINE_MODE_OFF,
	TOGGLING_MODE_DRP,
	TOGGLING_MODE_SNK,
	TOGGLING_MODE_SRC,
};

static const char * const toggling_mode_name[] = {
	[TOGGLINE_MODE_OFF]	= "toggling_OFF",
	[TOGGLING_MODE_DRP]	= "toggling_DRP",
	[TOGGLING_MODE_SNK]	= "toggling_SNK",
	[TOGGLING_MODE_SRC]	= "toggling_SRC",
};

enum src_current_status {
	SRC_CURRENT_DEFAULT,
	SRC_CURRENT_MEDIUM,
	SRC_CURRENT_HIGH,
};

static const u8 ra_mda_value[] = {
	[SRC_CURRENT_DEFAULT] = 4,	/* 210mV */
	[SRC_CURRENT_MEDIUM] = 9,	/* 420mV */
	[SRC_CURRENT_HIGH] = 18,	/* 798mV */
};

static const u8 rd_mda_value[] = {
	[SRC_CURRENT_DEFAULT] = 38,	/* 1638mV */
	[SRC_CURRENT_MEDIUM] = 38,	/* 1638mV */
	[SRC_CURRENT_HIGH] = 61,	/* 2604mV */
};

#define LOG_BUFFER_ENTRIES	1024
#define LOG_BUFFER_ENTRY_SIZE	128

struct fusb302_chip {
	struct device *dev;
	struct i2c_client *i2c_client;
	struct tcpm_port *tcpm_port;
	struct tcpc_dev tcpc_dev;

	struct regulator *vbus;

	int gpio_int_n;
	int gpio_int_n_irq;

	struct workqueue_struct *wq;
	struct delayed_work bc_lvl_handler;

	atomic_t pm_suspend;
	atomic_t i2c_busy;

	/* lock for sharing chip states */
	struct mutex lock;

	/* chip status */
	enum toggling_mode toggling_mode;
	enum src_current_status src_current_status;
	bool intr_togdone;
	bool intr_bc_lvl;
	bool intr_comp_chng;

	/* port status */
	bool pull_up;
	bool vconn_on;
	bool vbus_on;
	bool charge_on;
	bool vbus_present;
	enum typec_cc_polarity cc_polarity;
	enum typec_cc_status cc1;
	enum typec_cc_status cc2;

#ifdef CONFIG_DEBUG_FS
	struct dentry *dentry;
	/* lock for log buffer access */
	struct mutex logbuffer_lock;
	int logbuffer_head;
	int logbuffer_tail;
	u8 *logbuffer[LOG_BUFFER_ENTRIES];
#endif
};

/*
 * Logging
 */

#ifdef CONFIG_DEBUG_FS

static bool fusb302_log_full(struct fusb302_chip *chip)
{
	return chip->logbuffer_tail ==
		(chip->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;
}

static void _fusb302_log(struct fusb302_chip *chip, const char *fmt,
			 va_list args)
{
	char tmpbuffer[LOG_BUFFER_ENTRY_SIZE];
	u64 ts_nsec = local_clock();
	unsigned long rem_nsec;

	if (!chip->logbuffer[chip->logbuffer_head]) {
		chip->logbuffer[chip->logbuffer_head] =
				kzalloc(LOG_BUFFER_ENTRY_SIZE, GFP_KERNEL);
		if (!chip->logbuffer[chip->logbuffer_head])
			return;
	}

	vsnprintf(tmpbuffer, sizeof(tmpbuffer), fmt, args);

	mutex_lock(&chip->logbuffer_lock);

	if (fusb302_log_full(chip)) {
		chip->logbuffer_head = max(chip->logbuffer_head - 1, 0);
		strlcpy(tmpbuffer, "overflow", sizeof(tmpbuffer));
	}

	if (chip->logbuffer_head < 0 ||
	    chip->logbuffer_head >= LOG_BUFFER_ENTRIES) {
		dev_warn(chip->dev,
			 "Bad log buffer index %d\n", chip->logbuffer_head);
		goto abort;
	}

	if (!chip->logbuffer[chip->logbuffer_head]) {
		dev_warn(chip->dev,
			 "Log buffer index %d is NULL\n", chip->logbuffer_head);
		goto abort;
	}

	rem_nsec = do_div(ts_nsec, 1000000000);
	scnprintf(chip->logbuffer[chip->logbuffer_head],
		  LOG_BUFFER_ENTRY_SIZE, "[%5lu.%06lu] %s",
		  (unsigned long)ts_nsec, rem_nsec / 1000,
		  tmpbuffer);
	chip->logbuffer_head = (chip->logbuffer_head + 1) % LOG_BUFFER_ENTRIES;

abort:
	mutex_unlock(&chip->logbuffer_lock);
}

static void fusb302_log(struct fusb302_chip *chip, const char *fmt, ...)
{
	va_list args;

	va_start(args, fmt);
	_fusb302_log(chip, fmt, args);
	va_end(args);
}

static int fusb302_seq_show(struct seq_file *s, void *v)
{
	struct fusb302_chip *chip = (struct fusb302_chip *)s->private;
	int tail;

	mutex_lock(&chip->logbuffer_lock);
	tail = chip->logbuffer_tail;
	while (tail != chip->logbuffer_head) {
		seq_printf(s, "%s\n", chip->logbuffer[tail]);
		tail = (tail + 1) % LOG_BUFFER_ENTRIES;
	}
	if (!seq_has_overflowed(s))
		chip->logbuffer_tail = tail;
	mutex_unlock(&chip->logbuffer_lock);

	return 0;
}

static int fusb302_debug_open(struct inode *inode, struct file *file)
{
	return single_open(file, fusb302_seq_show, inode->i_private);
}

static const struct file_operations fusb302_debug_operations = {
	.open		= fusb302_debug_open,
	.llseek		= seq_lseek,
	.read		= seq_read,
	.release	= single_release,
};

static struct dentry *rootdir;

static int fusb302_debugfs_init(struct fusb302_chip *chip)
{
	mutex_init(&chip->logbuffer_lock);
	if (!rootdir) {
		rootdir = debugfs_create_dir("fusb302", NULL);
		if (!rootdir)
			return -ENOMEM;
	}

	chip->dentry = debugfs_create_file(dev_name(chip->dev),
					   S_IFREG | 0444, rootdir,
					   chip, &fusb302_debug_operations);

	return 0;
}

static void fusb302_debugfs_exit(struct fusb302_chip *chip)
{
	debugfs_remove(chip->dentry);
}

#else

static void fusb302_log(const struct fusb302_chip *chip,
			const char *fmt, ...) { }
static int fusb302_debugfs_init(const struct fusb302_chip *chip) { return 0; }
static void fusb302_debugfs_exit(const struct fusb302_chip *chip) { }

#endif

#define FUSB302_RESUME_RETRY 10
#define FUSB302_RESUME_RETRY_SLEEP 50

static bool fusb302_is_suspended(struct fusb302_chip *chip)
{
	int retry_cnt;

	for (retry_cnt = 0; retry_cnt < FUSB302_RESUME_RETRY; retry_cnt++) {
		if (atomic_read(&chip->pm_suspend)) {
			dev_err(chip->dev, "i2c: pm suspend, retry %d/%d\n",
				retry_cnt + 1, FUSB302_RESUME_RETRY);
			msleep(FUSB302_RESUME_RETRY_SLEEP);
		} else {
			return false;
		}
	}

	return true;
}

static int fusb302_i2c_write(struct fusb302_chip *chip,
			     u8 address, u8 data)
{
	int ret = 0;

	atomic_set(&chip->i2c_busy, 1);

	if (fusb302_is_suspended(chip)) {
		atomic_set(&chip->i2c_busy, 0);
		return -ETIMEDOUT;
	}

	ret = i2c_smbus_write_byte_data(chip->i2c_client, address, data);
	if (ret < 0)
		fusb302_log(chip, "cannot write 0x%02x to 0x%02x, ret=%d",
			    data, address, ret);
	atomic_set(&chip->i2c_busy, 0);

	return ret;
}

static int fusb302_i2c_block_write(struct fusb302_chip *chip, u8 address,
				   u8 length, const u8 *data)
{
	int ret = 0;

	if (length <= 0)
		return ret;
	atomic_set(&chip->i2c_busy, 1);

	if (fusb302_is_suspended(chip)) {
		atomic_set(&chip->i2c_busy, 0);
		return -ETIMEDOUT;
	}

	ret = i2c_smbus_write_i2c_block_data(chip->i2c_client, address,
					     length, data);
	if (ret < 0)
		fusb302_log(chip, "cannot block write 0x%02x, len=%d, ret=%d",
			    address, length, ret);
	atomic_set(&chip->i2c_busy, 0);

	return ret;
}

static int fusb302_i2c_read(struct fusb302_chip *chip,
			    u8 address, u8 *data)
{
	int ret = 0;

	atomic_set(&chip->i2c_busy, 1);

	if (fusb302_is_suspended(chip)) {
		atomic_set(&chip->i2c_busy, 0);
		return -ETIMEDOUT;
	}

	ret = i2c_smbus_read_byte_data(chip->i2c_client, address);
	*data = (u8)ret;
	if (ret < 0)
		fusb302_log(chip, "cannot read %02x, ret=%d", address, ret);
	atomic_set(&chip->i2c_busy, 0);

	return ret;
}

static int fusb302_i2c_block_read(struct fusb302_chip *chip, u8 address,
				  u8 length, u8 *data)
{
	int ret = 0;

	if (length <= 0)
		return ret;
	atomic_set(&chip->i2c_busy, 1);

	if (fusb302_is_suspended(chip)) {
		atomic_set(&chip->i2c_busy, 0);
		return -ETIMEDOUT;
	}

	ret = i2c_smbus_read_i2c_block_data(chip->i2c_client, address,
					    length, data);
	if (ret < 0) {
		fusb302_log(chip, "cannot block read 0x%02x, len=%d, ret=%d",
			    address, length, ret);
		goto done;
	}
	if (ret != length) {
		fusb302_log(chip, "only read %d/%d bytes from 0x%02x",
			    ret, length, address);
		ret = -EIO;
	}

done:
	atomic_set(&chip->i2c_busy, 0);

	return ret;
}

static int fusb302_i2c_mask_write(struct fusb302_chip *chip, u8 address,
				  u8 mask, u8 value)
{
	int ret = 0;
	u8 data;

	ret = fusb302_i2c_read(chip, address, &data);
	if (ret < 0)
		return ret;
	data &= ~mask;
	data |= value;
	ret = fusb302_i2c_write(chip, address, data);
	if (ret < 0)
		return ret;

	return ret;
}

static int fusb302_i2c_set_bits(struct fusb302_chip *chip, u8 address,
				u8 set_bits)
{
	return fusb302_i2c_mask_write(chip, address, 0x00, set_bits);
}

static int fusb302_i2c_clear_bits(struct fusb302_chip *chip, u8 address,
				  u8 clear_bits)
{
	return fusb302_i2c_mask_write(chip, address, clear_bits, 0x00);
}

static int fusb302_sw_reset(struct fusb302_chip *chip)
{
	int ret = 0;

	ret = fusb302_i2c_write(chip, FUSB_REG_RESET,
				FUSB_REG_RESET_SW_RESET);
	if (ret < 0)
		fusb302_log(chip, "cannot sw reset the chip, ret=%d", ret);
	else
		fusb302_log(chip, "sw reset");

	return ret;
}

static int fusb302_enable_tx_auto_retries(struct fusb302_chip *chip)
{
	int ret = 0;

	ret = fusb302_i2c_set_bits(chip, FUSB_REG_CONTROL3,
				   FUSB_REG_CONTROL3_N_RETRIES_3 |
				   FUSB_REG_CONTROL3_AUTO_RETRY);

	return ret;
}

/*
 * initialize interrupt on the chip
 * - unmasked interrupt: VBUS_OK
 */
static int fusb302_init_interrupt(struct fusb302_chip *chip)
{
	int ret = 0;

	ret = fusb302_i2c_write(chip, FUSB_REG_MASK,
				0xFF & ~FUSB_REG_MASK_VBUSOK);
	if (ret < 0)
		return ret;
	ret = fusb302_i2c_write(chip, FUSB_REG_MASKA, 0xFF);
	if (ret < 0)
		return ret;
	ret = fusb302_i2c_write(chip, FUSB_REG_MASKB, 0xFF);
	if (ret < 0)
		return ret;
	ret = fusb302_i2c_clear_bits(chip, FUSB_REG_CONTROL0,
				     FUSB_REG_CONTROL0_INT_MASK);
	if (ret < 0)
		return ret;

	return ret;
}

static int fusb302_set_power_mode(struct fusb302_chip *chip, u8 power_mode)
{
	int ret = 0;

	ret = fusb302_i2c_write(chip, FUSB_REG_POWER, power_mode);

	return ret;
}

static int tcpm_init(struct tcpc_dev *dev)
{
	struct fusb302_chip *chip = container_of(dev, struct fusb302_chip,
						 tcpc_dev);
	int ret = 0;
	u8 data;

	ret = fusb302_sw_reset(chip);
	if (ret < 0)
		return ret;
	ret = fusb302_enable_tx_auto_retries(chip);
	if (ret < 0)
		return ret;
	ret = fusb302_init_interrupt(chip);
	if (ret < 0)
		return ret;
	ret = fusb302_set_power_mode(chip, FUSB_REG_POWER_PWR_ALL);
	if (ret < 0)
		return ret;
	ret = fusb302_i2c_read(chip, FUSB_REG_STATUS0, &data);
	if (ret < 0)
		return ret;
	chip->vbus_present = !!(data & FUSB_REG_STATUS0_VBUSOK);
	ret = fusb302_i2c_read(chip, FUSB_REG_DEVICE_ID, &data);
	if (ret < 0)
		return ret;
	fusb302_log(chip, "fusb302 device ID: 0x%02x", data);

	return ret;
}

static int tcpm_get_vbus(struct tcpc_dev *dev)
{
	struct fusb302_chip *chip = container_of(dev, struct fusb302_chip,
						 tcpc_dev);
	int ret = 0;

	mutex_lock(&chip->lock);
	ret = chip->vbus_present ? 1 : 0;
	mutex_unlock(&chip->lock);

	return ret;
}

static int fusb302_set_cc_pull(struct fusb302_chip *chip,
			       bool pull_up, bool pull_down)
{
	int ret = 0;
	u8 data = 0x00;
	u8 mask = FUSB_REG_SWITCHES0_CC1_PU_EN |
		  FUSB_REG_SWITCHES0_CC2_PU_EN |
		  FUSB_REG_SWITCHES0_CC1_PD_EN |
		  FUSB_REG_SWITCHES0_CC2_PD_EN;

	if (pull_up)
		data |= (chip->cc_polarity == TYPEC_POLARITY_CC1) ?
			FUSB_REG_SWITCHES0_CC1_PU_EN :
			FUSB_REG_SWITCHES0_CC2_PU_EN;
	if (pull_down)
		data |= FUSB_REG_SWITCHES0_CC1_PD_EN |
			FUSB_REG_SWITCHES0_CC2_PD_EN;
	ret = fusb302_i2c_mask_write(chip, FUSB_REG_SWITCHES0,
				     mask, data);
	if (ret < 0)
		return ret;
	chip->pull_up = pull_up;

	return ret;
}

static int fusb302_set_src_current(struct fusb302_chip *chip,
				   enum src_current_status status)
{
	int ret = 0;

	chip->src_current_status = status;
	switch (status) {
	case SRC_CURRENT_DEFAULT:
		ret = fusb302_i2c_mask_write(chip, FUSB_REG_CONTROL0,
					     FUSB_REG_CONTROL0_HOST_CUR_MASK,
					     FUSB_REG_CONTROL0_HOST_CUR_DEF);
		break;
	case SRC_CURRENT_MEDIUM:
		ret = fusb302_i2c_mask_write(chip, FUSB_REG_CONTROL0,
					     FUSB_REG_CONTROL0_HOST_CUR_MASK,
					     FUSB_REG_CONTROL0_HOST_CUR_MED);
		break;
	case SRC_CURRENT_HIGH:
		ret = fusb302_i2c_mask_write(chip, FUSB_REG_CONTROL0,
					     FUSB_REG_CONTROL0_HOST_CUR_MASK,
					     FUSB_REG_CONTROL0_HOST_CUR_HIGH);
		break;
	default:
		break;
	}

	return ret;
}

static int fusb302_set_toggling(struct fusb302_chip *chip,
				enum toggling_mode mode)
{
	int ret = 0;

	/* first disable toggling */
	ret = fusb302_i2c_clear_bits(chip, FUSB_REG_CONTROL2,
				     FUSB_REG_CONTROL2_TOGGLE);
	if (ret < 0)
		return ret;
	/* mask interrupts for SRC or SNK */
	ret = fusb302_i2c_set_bits(chip, FUSB_REG_MASK,
				   FUSB_REG_MASK_BC_LVL |
				   FUSB_REG_MASK_COMP_CHNG);
	if (ret < 0)
		return ret;
	chip->intr_bc_lvl = false;
	chip->intr_comp_chng = false;
	/* configure toggling mode: none/snk/src/drp */
	switch (mode) {
	case TOGGLINE_MODE_OFF:
		ret = fusb302_i2c_mask_write(chip, FUSB_REG_CONTROL2,
					     FUSB_REG_CONTROL2_MODE_MASK,
					     FUSB_REG_CONTROL2_MODE_NONE);
		if (ret < 0)
			return ret;
		break;
	case TOGGLING_MODE_SNK:
		ret = fusb302_i2c_mask_write(chip, FUSB_REG_CONTROL2,
					     FUSB_REG_CONTROL2_MODE_MASK,
					     FUSB_REG_CONTROL2_MODE_UFP);
		if (ret < 0)
			return ret;
		break;
	case TOGGLING_MODE_SRC:
		ret = fusb302_i2c_mask_write(chip, FUSB_REG_CONTROL2,
					     FUSB_REG_CONTROL2_MODE_MASK,
					     FUSB_REG_CONTROL2_MODE_DFP);
		if (ret < 0)
			return ret;
		break;
	case TOGGLING_MODE_DRP:
		ret = fusb302_i2c_mask_write(chip, FUSB_REG_CONTROL2,
					     FUSB_REG_CONTROL2_MODE_MASK,
					     FUSB_REG_CONTROL2_MODE_DRP);
		if (ret < 0)
			return ret;
		break;
	default:
		break;