|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 ^& K4 `2 D8 T' a1 ^
#include <linux/init.h>
6 B2 x6 L0 I! k y#include <linux/module.h>0 k( N9 g- I. [ Y# h
#include <linux/kernel.h>3 Q' s8 T& y/ `3 o
#include <linux/types.h>8 U7 D+ q: j) Q& i5 b
#include <linux/gpio.h>8 l& n7 N4 Q$ g3 c
#include <linux/leds.h>
+ C( C. J! Z; P#include <linux/platform_device.h>
+ c' A/ U' K; o/ A2 [1 L( F
6 x" g, V4 L# ^+ s. c#include <asm/mach-types.h>
# e2 F" E8 g$ T* {! s#include <asm/mach/arch.h>
# C: O* E" H: M: K$ H* ?#include <mach/da8xx.h>! b) J3 D3 L) ^
#include <mach/mux.h>
- _3 l( C9 ^' |0 c/ X+ Z4 r* @& v* k1 t! z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 _. c7 G0 [' d2 Q8 |& n( E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# W6 r5 t" x3 |: q! r3 I( v) k5 l/ T$ g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' O, T5 h5 f/ M% Y" U#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ J. l4 h! \1 _( \1 B& S/ k) H
: m( l- L. P9 n) G
/* assign the tl som board LED-GPIOs*/6 V$ o5 d/ D- v; E0 h
static const short da850_evm_tl_user_led_pins[] = {9 y3 h( ^0 q- e! r9 W
/* These pins are definition at <mach/mux.h> file */5 y# J- P1 |+ E& u G
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) L6 S' l& Z/ v9 {: j7 ` -1
2 e* r# h1 m" p- K. Q};
+ R+ t/ J1 D$ ^
, x. P- R9 `) O% r8 sstatic struct gpio_led da850_evm_tl_leds[] = {
1 L5 L4 W2 e2 v1 B0 m- w {4 a' d( c. V e9 K6 E& b, J8 l
.active_low = 0,5 s% E Z7 v$ ?( t n. v
.gpio = DA850_USER_LED0,
7 `; m3 X; ^1 c( Q .name = "user_led0",: F5 b& i1 s: t0 ^
.default_trigger = "default-on",
6 J. @5 `, c- P6 |( A4 s },
: U* p6 ^7 |4 L2 e {. w# M: @" |" o5 b- e3 X* L
.active_low = 0,
' `# t/ i! f- o' h4 f/ s .gpio = DA850_USER_LED1,
6 @7 m. M# q& a9 U2 `( I/ C1 e/ u .name = "user_led1",
7 q( B6 x8 ^: k/ D .default_trigger = "default-on",
" B- B) n! N; {) C( d, M },/ `8 K" q: C. x
{5 g% x+ w& `$ D1 U; W
.active_low = 0,
u* D# l2 ^5 `- p% K3 m .gpio = DA850_USER_LED2,1 e- k6 S0 Y- L* ^
.name = "user_led2",
- [; Y' N( x4 Y: H8 Q- w .default_trigger = "default-on",
! [7 R5 V# n3 z, D },. \9 K, e5 n" w+ x
{
0 {) m" K( O2 n* M0 v' ~0 V .active_low = 0,$ M! @4 m6 }* z$ t" A5 _: ~$ a4 y
.gpio = DA850_USER_LED3,
+ k; _+ ]! w& J1 t! S% o .name = "user_led3",* C; b) R$ \: }7 N6 M
.default_trigger = "default-on",1 s+ z) z* ?# g) Y/ K
},
" N& C( c( I1 h& J* z};) v6 H2 I& O4 }6 W& y, E/ l
; G, T" H, R% r5 g( F; ?0 e9 y Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 ?. `) N2 _ ]. F9 e
.leds = da850_evm_tl_leds,6 ?3 n+ A F: z; _/ }9 a" t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. u& B5 W2 C$ \- H1 F/ h! t$ Q};
5 P& O+ r( S& n1 ?7 d8 \" m) ? |! C! d! X
static void led_dev_release(struct device *dev)
0 }) G5 h1 q# [' m1 {( D+ y{/ s* t, ^9 }& H9 a
};
' C* A5 e9 L2 s, Q" W7 g" P# L; ^8 w; S& e
static struct platform_device da850_evm_tl_leds_device = {
) T/ X7 V- U7 s .name = "leds-gpio",8 b7 Y" w% Y/ `% u: q- n& F
.id = 1,
- O/ Q# o9 a: E2 q9 G5 r& w0 s .dev = {. N0 {" D6 {- C# v2 n6 j4 b3 _
.platform_data = &da850_evm_tl_leds_pdata,
' m! O0 i5 U# P) h) G .release = led_dev_release,) ?5 Q! _3 b1 }6 g P9 U. {, N6 t
}
8 H; v8 l: O: F; A};2 p7 f O" Y8 _
7 l. h3 j. v+ v& Z: P* a1 nstatic int __init led_platform_init(void)
+ L- A: T1 o9 w& g{
- s7 N. G1 e" P# A int ret;; w5 b9 J0 g7 H# r# i' A3 P
#if 0
' S/ J' V5 s3 e) o- I# y; { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; A" Q4 k9 f: Z0 z# _ if (ret)
. K( q% i( a9 y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! `% [' K; D) V6 e8 f8 Y) f6 h
"%d\n", ret);; h: {5 V4 M- q5 X$ M a; L- ^; S3 e
#endif" l5 L# w0 j' b, @. q/ l4 e4 i- K
ret = platform_device_register(&da850_evm_tl_leds_device);. I% M& P9 u( r, L0 @4 E5 E1 ?) h' Q* `
if (ret)1 [7 l' H( G7 ~! A" \
pr_warning("Could not register som GPIO expander LEDS");
# W" a$ [* v/ I, v! R' h3 [ else. j' x" |1 N3 ~( w7 E- z" L) ^
printk(KERN_INFO "LED register sucessful!\n");* d2 ?) g9 M: V# f ~
) l- V3 F8 m* ]! `; i& e* J% D4 u return ret;
$ `$ O% I4 @8 q# N6 z% M}
7 G* s: }5 k/ G* Z3 q1 K. [; ]0 a: m. u' b: t9 k1 Y" q
static void __exit led_platform_exit(void)" L% B; T" G0 s
{0 D5 q( q1 E4 X, y
platform_device_unregister(&da850_evm_tl_leds_device);1 A( } a! _( U% P. q
$ }0 c$ U4 C9 j* a printk(KERN_INFO "LED unregister!\n");6 @# ~# t, l6 j; u& n) l( h j. y
}3 a& P& Q" {" g
: `& d/ x$ b4 A! P- w6 c. Vmodule_init(led_platform_init);
8 r( t! I: T2 r% Cmodule_exit(led_platform_exit);
5 j. |9 K/ B5 e) f
- b) v7 l1 [% n& `" lMODULE_DESCRIPTION("Led platform driver");
6 t9 O& Z) g# R. _8 c |MODULE_AUTHOR("Tronlong");. h1 j( O0 k* [% Q: s
MODULE_LICENSE("GPL");0 A. b4 P! F9 [
* d" I2 y* C, m& G$ ~ |
|