summaryrefslogtreecommitdiff
path: root/lib/core/os.h
blob: 7f23f9ad03fc0645a71938d87783690f9d5adc24 (plain)
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
/*
 * Copyright 2012 Red Hat 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 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
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
 *
 * Authors: Ben Skeggs
 */

#ifndef __NOUVEAU_OS_H__
#define __NOUVEAU_OS_H__

/******************************************************************************
 * bootstrap interface
 *****************************************************************************/
struct nouveau_object;

int  os_client_new(char *cfg, char *dbg, int argc, char **argv,
		   struct nouveau_object **);
void os_client_del(struct nouveau_object **);
void os_suspend(void);
void os_resume(void);
void os_backtrace(void);

/******************************************************************************
 * types
 *****************************************************************************/
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>

#define u64 uint64_t
#define u32 uint32_t
#define u16 uint16_t
#define u8 uint8_t

#define s32 int32_t
#define s16 int16_t
#define s8 int8_t

/******************************************************************************
 * various random macros
 *****************************************************************************/
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define max_t(t,a,b) max((t)(a), (t)(b))
#define min_t(t,a,b) min((t)(a), (t)(b))
#define clamp(a,b,c) min(max((a), (b)), (c))
#define roundup(a,b) ((((a) + ((b) - 1)) / (b)) * (b))
#define round_up(a,b) roundup((a), (b))
#define rounddown(a,b) ((a) / (b) * (b))
#define upper_32_bits(a) ((a) >> 32)
#define lower_32_bits(a) ((a) & 0xffffffff)
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
#define do_div(a,b) (a) = (a) / (b)
#define likely(a) (a)
#define unlikely(a) (a)

#define usecs_to_jiffies(a) (a)
#define THIS_MODULE 0
#define request_module(a,b,c)

#define PAGE_SHIFT 12
#define PAGE_SIZE (1 << PAGE_SHIFT)
#define PAGE_MASK (PAGE_SHIFT - 1)

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#define __acquires(a)
#define __releases(a)
#define __printf(a,b)
#define __user

static inline int
order_base_2(u64 base)
{
	u64 temp = base >> 1;
	int log2;

	for (log2 = 0; temp; log2++, temp >>= 1) {
	}

	return (base & (base - 1)) ? log2 + 1: log2;
}

/******************************************************************************
 * endianness
 *****************************************************************************/

#define le16_to_cpu(a) (a)
#define le32_to_cpu(a) (a)
#define cpu_to_le16(a) (a)
#define cpu_to_le32(a) (a)

/******************************************************************************
 * unaligned access
 *****************************************************************************/

static inline u16
get_unaligned_le16(void *ptr)
{
	return le16_to_cpu(*(u16 *)ptr);
}

static inline u32
get_unaligned_le32(void *ptr)
{
	return le32_to_cpu(*(u32 *)ptr);
}

static inline void
put_unaligned_le16(u16 val, void *ptr)
{
	*(u16 *)ptr = cpu_to_le16(val);
}

static inline void
put_unaligned_le32(u32 val, void *ptr)
{
	*(u32 *)ptr = cpu_to_le32(val);
}

/******************************************************************************
 * bitops
 *****************************************************************************/
#define ffsll(a) __builtin_ffsll(a)

static inline int
hweight8(u32 v) {
	int i = 0;
	while (v) {
		i += (v & 1);
		v >>= 1;
	}
	return i;
}

static inline int
hweight32(u32 v) {
	int i = 0;
	while (v) {
		i += (v & 1);
		v >>= 1;
	}
	return i;
}

static inline int
test_bit(int bit, volatile unsigned long *ptr)
{
	return !!(*ptr & (1 << bit));
}

static inline int
__test_and_clear_bit(int bit, volatile unsigned long *ptr)
{
	int ret = test_bit(bit, ptr);
	*ptr &= ~(1L << bit);
	return ret;
}

static inline int
test_and_clear_bit(int bit, volatile unsigned long *ptr)
{
	return !!(__sync_fetch_and_and(ptr, ~(1L << bit)) & (1L << bit));
}

static inline int
__test_and_set_bit(int bit, volatile unsigned long *ptr)
{
	int ret = test_bit(bit, ptr);
	*ptr |= (1L << bit);
	return ret;
}

static inline int
test_and_set_bit(int bit, volatile unsigned long *ptr)
{
	 return !(__sync_fetch_and_or(ptr, (1L << bit)) & (1L << bit));
}

/******************************************************************************
 * atomics
 *****************************************************************************/
typedef struct atomic {
	int value;
} atomic_t;

#define atomic_read(a) ((a)->value)
#define atomic_set(a,b) ((a)->value = (b))
#define atomic_inc(a) ((void) __sync_fetch_and_add (&(a)->value, 1))
#define atomic_dec(a) ((void) __sync_fetch_and_add (&(a)->value, -1))
#define atomic_add(a,b) ((void) __sync_add_and_fetch(&(a)->value, (b)))
#define atomic_add_return(b,a) (__sync_add_and_fetch(&(a)->value, (b)))
#define atomic_inc_return(a) atomic_add_return(1, (a))
#define atomic_dec_return(a) atomic_add_return(-1, (a))
#define atomic_dec_and_test(a) (atomic_dec_return(a) == 0)

/******************************************************************************
 * krefs
 *****************************************************************************/
struct kref {
	atomic_t refcount;
};

#define kref_init(a) atomic_set(&(a)->refcount, 1)
#define kref_get(a) atomic_inc(&(a)->refcount)
#define kref_put(a,b) if (atomic_dec_and_test(&(a)->refcount)) b(a)

/******************************************************************************
 * string
 *****************************************************************************/
#include <string.h>

#define kstrdup(a,b) strdup((a))
#define kstrndup(a,b,c) strndup((a), (b))

/******************************************************************************
 * printk
 *****************************************************************************/
#include <stdarg.h>
#include <stdio.h>

#define KERN_CRIT ""
#define KERN_ERR ""
#define KERN_WARNING ""
#define KERN_INFO ""
#define KERN_DEBUG ""

#define printk printf
#define vprintk vprintf
#define pr_cont printf

/******************************************************************************
 * memory
 *****************************************************************************/
#include <stdlib.h>

#define GFP_KERNEL 1
#define __GFP_ZERO 2
#define GFP_DMA32  4

typedef unsigned gfp_t;

#define vmalloc malloc
#define vfree free
#define kmalloc(a,b) malloc((a))
#define kzalloc(a,b) calloc(1, (a))
#define kcalloc(a,b,c) calloc((a), (b))
#define kfree free

#define vzalloc(a) calloc(1, (a))
#define vfree free

static inline void *
kmemdup(const void *src, size_t len, gfp_t gfp)
{
	void *dst = malloc(len);
	if (dst)
		memcpy(dst, src, len);
	return dst;
}

struct page {
};

static inline struct page *
alloc_page(gfp_t gfp)
{
	return NULL;
}

static inline void
__free_page(struct page *page)
{
}

/******************************************************************************
 * assertions
 *****************************************************************************/
#include <errno.h>
#include <assert.h>
#include <execinfo.h>

static inline void
nvos_backtrace(void)
{
	void *buffer[512];
	char **sinfo;
	int ninfo, i;

	ninfo = backtrace(buffer, sizeof(buffer));
	sinfo = backtrace_symbols(buffer, ninfo);
	if (sinfo) {
		for (i = 0; i < ninfo; i++)
			printf("%s\n", sinfo[i]);
		free(sinfo);
	}
}

#define BUG() do {                                                             \
	printk("BUG at %s:%d/%s()!\n\n", __FILE__, __LINE__, __func__);        \
	nvos_backtrace();                                                      \
	assert(0);                                                             \
} while(0)

#define BUG_ON(c) do { if ((c)) BUG(); } while(0)

#define WARN() do {                                                            \
	printk("WARNING at %s:%d/%s()!\n\n", __FILE__, __LINE__, __func__);    \
	nvos_backtrace();                                                      \
} while(0)

#define WARN_ON(c) (c)

/******************************************************************************
 * interrupts
 *****************************************************************************/
#define IRQF_SHARED 0

typedef enum irqreturn {
	IRQ_NONE,
	IRQ_HANDLED
} irqreturn_t;

typedef irqreturn_t (*irq_handler_t)(int, void *);

extern int  os_intr_init(unsigned int, irq_handler_t, unsigned long,
			 const char *, void *);
extern void os_intr_free(unsigned int, void *);

#define request_irq os_intr_init
#define free_irq os_intr_free

/******************************************************************************
 * spinlocks - using pthread mutex due to no static spinlock initialiser
 *****************************************************************************/
#include <pthread.h>

typedef struct spinlock_t {
	pthread_mutex_t lock;
} spinlock_t;

#define DEFINE_SPINLOCK(a) spinlock_t a = { .lock = PTHREAD_MUTEX_INITIALIZER }

#define spin_lock_init(a) pthread_mutex_init(&(a)->lock, NULL)
#define spin_lock(a) pthread_mutex_lock(&(a)->lock)
#define spin_unlock(a) pthread_mutex_unlock(&(a)->lock)
#define spin_lock_irqsave(a,b) do { (b) = 1; spin_lock((a)); } while (0)
#define spin_unlock_irqrestore(a,b) do { (void)(b); spin_unlock((a)); } while (0)

/******************************************************************************
 * rwlocks
 *****************************************************************************/
typedef struct rwlock_t {
	pthread_rwlock_t lock;
} rwlock_t;

#define rwlock_init(a) pthread_rwlock_init(&(a)->lock, PTHREAD_PROCESS_PRIVATE)
#define read_lock(a) pthread_rwlock_rdlock(&(a)->lock)
#define read_unlock(a) pthread_rwlock_unlock(&(a)->lock)
#define write_lock_irq(a) pthread_rwlock_wrlock(&(a)->lock)
#define write_unlock_irq(a) pthread_rwlock_unlock(&(a)->lock)

/******************************************************************************
 * mutexes
 *****************************************************************************/
struct mutex {
	pthread_mutex_t mutex;
};

#define DEFINE_MUTEX(a) struct mutex a = { .mutex = PTHREAD_MUTEX_INITIALIZER }
#define mutex_init(a) pthread_mutex_init(&(a)->mutex, NULL)
#define mutex_lock(a) pthread_mutex_lock(&(a)->mutex)
#define mutex_unlock(a) pthread_mutex_unlock(&(a)->mutex)

/******************************************************************************
 * lockdep
 *****************************************************************************/
struct lock_class_key {
};

#define __mutex_init(a,b,c) pthread_mutex_init(&(a)->mutex, NULL)

/******************************************************************************
 * lists
 *****************************************************************************/
#include "list.h"

/******************************************************************************
 * io space
 *****************************************************************************/
#define __iomem

void __iomem *nvos_ioremap(u64 addr, u64 size);
void  nvos_iounmap(void __iomem *ptr);

#define ioremap(a,b) nvos_ioremap((a), (b))
#define iounmap(a) nvos_iounmap((a))

#define ioread8(a) *((volatile u8 *)(a))
#define ioread16(a) *((volatile u16 *)(a))
#define ioread16_native ioread16
#define ioread32(a) *((volatile u32 *)(a))
#define ioread32_native ioread32

#define iowrite8(b,a) *((volatile u8 *)(a)) = (b)
#define iowrite16(b,a) *((volatile u16 *)(a)) = (b)
#define iowrite16_native iowrite16
#define iowrite32(b,a) *((volatile u32 *)(a)) = (b)
#define iowrite32_native iowrite32

#define memcpy_fromio memcpy
#define memcpy_toio memcpy
#define wmb()

/******************************************************************************
 * io mapping
 *****************************************************************************/
struct io_mapping {
};

static inline struct io_mapping *
io_mapping_create_wc(u64 addr, u64 size)
{
	return NULL;
}

static inline void
io_mapping_free(struct io_mapping *io)
{
}

static inline void __iomem *
io_mapping_map_atomic_wc(struct io_mapping *io, u32 offset)
{
	return NULL;
}

static inline void
io_mapping_unmap_atomic(void __iomem *p)
{
}

/******************************************************************************
 * DMI
 *****************************************************************************/
struct dmi_strmatch {
};

struct dmi_system_id {
	const char *ident;
	struct dmi_strmatch matches[4];
};

#define DMI_MATCH(a, b) { }

static inline int
dmi_check_system(const struct dmi_system_id *list)
{
	return 0;
}

/******************************************************************************
 * Device
 *****************************************************************************/
struct device {
};

/******************************************************************************
 * PM runtime
 *****************************************************************************/
static inline void
pm_runtime_mark_last_busy(struct device *dev)
{
}

/******************************************************************************
 * PCI
 *****************************************************************************/
#include <pciaccess.h>

#define PCI_DMA_BIDIRECTIONAL 1

#define PCI_CAP_ID_AGP 0x02

typedef u64 dma_addr_t;

struct pci_dev {
	struct pci_device *pdev;
	struct device dev;
	u16 device;
	u16 subsystem_vendor;
	u16 subsystem_device;
	int irq;
};

static inline int
pci_find_capability(struct pci_dev *pdev, int cap)
{
	return 0;
}

static inline int
pci_write_config_byte(struct pci_dev *pdev, int addr, u8 data)
{
	return pci_device_cfg_write_u8(pdev->pdev, data, addr);
}

static inline u64
pci_resource_start(struct pci_dev *pdev, int bar)
{
	return pdev->pdev->regions[bar].base_addr;
}

static inline u64
pci_resource_len(struct pci_dev *pdev, int bar)
{
	return pdev->pdev->regions[bar].size;
}

static inline dma_addr_t
pci_map_page(struct pci_dev *pdev, struct page *page, int offset,
	     int length, unsigned flags)
{
	return 0;
}


static inline bool
pci_dma_mapping_error(struct pci_dev *pdev, dma_addr_t addr)
{
	return true;
}

static inline void
pci_unmap_page(struct pci_dev *pdev, dma_addr_t addr, int size, unsigned flags)
{
}

static inline int
pci_enable_rom(struct pci_dev *pdev)
{
	return 0;
}

static inline void
pci_disable_rom(struct pci_dev *pdev)
{
}

static inline void __iomem *
pci_map_rom(struct pci_dev *pdev, size_t *size)
{
	void *buf;
	*size = pdev->pdev->rom_size;
	buf = malloc(*size);
	if (buf) {
		if (pci_device_read_rom(pdev->pdev, buf)) {
			free(buf);
			buf = NULL;
		}
	}
	return buf;
}

static inline void
pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
{
	free(rom);
}

static inline void __iomem *
pci_platform_rom(struct pci_dev *pdev, size_t *size)
{
	return NULL;
}

static inline void *
pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
		     dma_addr_t *dma_handle)
{
	return NULL;
}

static inline void
pci_free_consistent(struct pci_dev *hwdev, size_t size,
		    void *vaddr, dma_addr_t dma_handle)
{
}

static inline int
pci_enable_msi(struct pci_dev *pdev)
{
	return -ENOSYS;
}

static inline void
pci_disable_msi(struct pci_dev *pdev)
{
}

#define PCI_DEVFN(a,b) 0
#define pci_get_bus_and_slot(a, b) NULL
#define pci_read_config_dword(a,b,c) *(c) = 0

/******************************************************************************
 * sg table
 *****************************************************************************/
struct scatterlist {
};

struct sg_table {
	struct scatterlist *sgl;
	unsigned int nents;
};

#define for_each_sg(sglist, sg, nr, __i)	                               \
	for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
#define sg_next(a) (a)
#define sg_dma_address(a) 0ULL
#define sg_dma_len(a) 0ULL

/******************************************************************************
 * firmware
 *****************************************************************************/
#include <unistd.h>
#include <fcntl.h>

struct firmware {
	size_t size;
	void *data;
};

static inline int
request_firmware(const struct firmware **pfw, const char *name,
		 struct device *dev)
{
	struct firmware *fw = *(void **)pfw = malloc(sizeof(*fw));
	int fd = open(name, O_RDONLY);
	if (fd >= 0) {
		off_t len = lseek(fd, 0, SEEK_END);
		fw->data = malloc(len);
		fw->size = pread(fd, fw->data, len, 0);
		return 0;
	}
	free(fw);
	return errno;
}

static inline void
release_firmware(const struct firmware *fw)
{
	free(fw->data);
	free((void *)fw);
}

/******************************************************************************
 * workstruct
 *****************************************************************************/
struct work_struct;

typedef void (*work_func_t)(struct work_struct *);

struct work_struct {
	work_func_t func;
	pthread_t thread;
};

#define INIT_WORK(a, b) (a)->func = (b)
#define schedule_work(a) do {                                                  \
	int ret = pthread_create(&(a)->thread, NULL, os_work, (a));            \
	assert(ret == 0);                                                      \
} while(0)
#define flush_work(a)

static inline void *
os_work(void *arg)
{
	struct work_struct *work = arg;
	work->func(work);
	return NULL;
}

/******************************************************************************
 * waitqueues
 *****************************************************************************/
typedef struct __wait_queue_head {
} wait_queue_head_t;

#define wake_up(wq)
#define wait_event(wq,cond) do {                                               \
	usleep(1);                                                             \
} while (!(cond))
#define init_waitqueue_head(wq)

/******************************************************************************
 * i2c
 *****************************************************************************/
struct i2c_adapter {
	struct {
		void *parent;
	} dev;
	const struct i2c_algorithm *algo;
	char name[48];
	void *algo_data;
	void *adapdata;
	int owner;
};

#define I2C_M_RD 1

struct i2c_msg {
	u16 addr;
	u16 flags;
	u16 len;
	u8 *buf;
};

#define I2C_FUNC_I2C 1
#define I2C_FUNC_SMBUS_EMUL 2

struct i2c_algorithm {
	int (*master_xfer)(struct i2c_adapter *, struct i2c_msg *, int);
	u32 (*functionality)(struct i2c_adapter *);
};

struct i2c_board_info {
	char type[64];
	unsigned short addr;
};

#define I2C_BOARD_INFO(a,b) .type = (a), .addr = (b)

struct i2c_client {
	struct i2c_driver *driver;
};

struct i2c_driver {
	int (*detect)(struct i2c_client *, struct i2c_board_info *);
};

static inline struct i2c_client *
i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
{
	return NULL;
}

static inline void
i2c_unregister_device(struct i2c_client *client)
{
}

static inline int
i2c_add_adapter(struct i2c_adapter *a)
{
	return 0;
}

static inline int
i2c_del_adapter(struct i2c_adapter *a)
{
	return 0;
}

static inline void *
i2c_get_adapdata(const struct i2c_adapter *a)
{
	return a->adapdata;
}

static inline void
i2c_set_adapdata(struct i2c_adapter *a, void *d)
{
	a->adapdata = d;
}

static inline int
i2c_transfer(struct i2c_adapter *a, struct i2c_msg *m, int num)
{
	if (a->algo)
		return a->algo->master_xfer(a, m, num);
	return -ENODEV;
}

/******************************************************************************
 * i2c bit-bang
 *****************************************************************************/

static struct i2c_algorithm
i2c_bit_algo = {
};

struct i2c_algo_bit_data {
	int udelay;
	int timeout;
	void *data;
	void (*setsda) (void *data, int state);
	void (*setscl) (void *data, int state);
	int  (*getsda) (void *data);
	int  (*getscl) (void *data);
	int  (*pre_xfer)(struct i2c_adapter *);
};

static inline int
i2c_bit_add_bus(struct i2c_adapter *a)
{
	(void)i2c_bit_algo;
	return 0;
}

/******************************************************************************
 * delay
 *****************************************************************************/
#include <unistd.h>

#define udelay(a) usleep((a))
#define mdelay(a) usleep((a) * 1000)
#define msleep(a) usleep((a) * 1000)
#define usleep_range(a,b) usleep((a))

/******************************************************************************
 * reboot
 *****************************************************************************/
static inline int
orderly_poweroff(bool force)
{
	BUG_ON(1);
}

#undef __BIG_ENDIAN
#endif