|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 y2 R& ^5 M" O1 G3 d, j& L
#include <linux/init.h>
5 i) x+ `" n9 K6 p$ r, P8 E( d0 J$ r#include <linux/module.h>
' D+ M; ]4 g) v' J3 z, } r9 ~#include <linux/kernel.h>2 l0 R, V! f$ M `
#include <linux/types.h>
6 a" s. q/ x, o9 y4 |% s#include <linux/gpio.h>! f" Q( W" T3 u9 h% |" z4 ^
#include <linux/leds.h>
8 M# @1 G- N$ X# f#include <linux/platform_device.h>( q5 Y# ~. N ? |7 x2 b3 y2 I
& V6 Z2 u- @6 ?8 x% ^6 S
#include <asm/mach-types.h>! {2 g( ^3 W2 f# e* u( Q
#include <asm/mach/arch.h>
9 e% e8 [& ?& Z& t#include <mach/da8xx.h>( b X) I4 c1 d6 E4 l4 q0 ^8 ?" G
#include <mach/mux.h>
c; R% x6 ?! @0 } _, x) o/ Y7 H {
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( |6 F% G- A; V( S. O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- [# f% U* V" u1 q) R/ f! J5 |% V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 x6 I- R# h t, O0 h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: D8 d. p2 r" c# y1 T. ~
* d! x( e6 w- c9 o: }/* assign the tl som board LED-GPIOs*/
( S( \' H' m2 }) m# F: u2 x( Cstatic const short da850_evm_tl_user_led_pins[] = {
' A$ O. L6 g: J /* These pins are definition at <mach/mux.h> file */7 r3 Y& x, ]! L, d$ {2 ~9 d' J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 u: |" j# V4 y3 s l9 T* I0 h/ l -1
. }- o/ x9 x2 N0 i% j};% \; }& p, R, }. C+ i$ T
n" G/ [; v! t. p L9 j* j
static struct gpio_led da850_evm_tl_leds[] = {# ?% t* P$ _ f; j: w: h
{
9 V! [& ?# U- `. k. [' b4 i$ @ .active_low = 0,2 w( p% X! o: Z# W, @
.gpio = DA850_USER_LED0,
6 b% o6 W. i6 H/ F .name = "user_led0",
3 f. K h* o1 V' Q .default_trigger = "default-on",/ |# E' T/ b8 _# a% \) ]7 i/ B
}," |7 b# U6 i( A& @3 {1 `9 i2 H
{" j* m3 M9 R3 k# o" {
.active_low = 0,
, S6 @% J% A4 i, a8 e. [6 X .gpio = DA850_USER_LED1,) j( q6 k- k' n, I2 a
.name = "user_led1",
: z' w, m; T& e( _& k .default_trigger = "default-on",
- t- S! R8 ^9 P0 i+ M4 y },& m4 L e: b" C$ r4 f8 A6 d% g. m
{
4 O# t- A$ l$ x7 ?3 Q- z, R .active_low = 0,* J8 G4 R' o+ S5 p
.gpio = DA850_USER_LED2,* m+ x7 S% V# ?' `- W' @. |% S1 h
.name = "user_led2",
, v$ d+ n$ L- @ e1 `% r .default_trigger = "default-on",: t+ v! S$ Q/ k
},
l- ?7 m: O- V. P. U& ? |4 z {7 v) p; F3 p2 O. e/ P
.active_low = 0,
3 k5 j) x# S& ]5 g5 R' { .gpio = DA850_USER_LED3,3 o% L. M1 D4 y" v( @, F( N
.name = "user_led3",
( Q' P9 j* E0 z# ]! u* D! P. | .default_trigger = "default-on",7 g {* ~- }# {, N% v/ u
},
$ ?- k0 N/ e( l5 [7 l};; h1 |( u9 _) U) `
/ f# p$ l4 G, r0 W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* d. V+ m* d6 J, j- `$ _' r4 c
.leds = da850_evm_tl_leds,
m) h7 S# G) M7 P) F3 R4 s .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 v% w3 ~) ~( A5 Q};
/ A& F8 g' c% }' a; c( y" Y1 G5 L: S/ ^( n& l
static void led_dev_release(struct device *dev); Y' m; e. ?9 Q
{
- y. D- c& D9 f: h. l3 f9 S) G};" n3 ]* X x3 c! T9 ^8 O' M1 O
9 W$ L( M# K( X' Nstatic struct platform_device da850_evm_tl_leds_device = {
- r. m! K% Z# j, s0 m .name = "leds-gpio",
7 l/ v+ h( J, I4 g* e4 X .id = 1,
( ?9 P9 W1 z' _+ Z .dev = {! a5 B$ E' C7 q. e2 h; k
.platform_data = &da850_evm_tl_leds_pdata,+ L0 `3 J8 V1 |! s
.release = led_dev_release,
: U! \: ^) C3 t) ^8 r2 r }7 ~7 H. g) z/ I; o$ ?
};- U$ \' ~9 E9 R. p+ P0 N1 I
+ I# k- ~% R. a2 A' X ostatic int __init led_platform_init(void)
* g, C, c/ X2 z% j6 M, S8 A{
$ S! X \- [2 L% R int ret;
* J; P$ C' G' {7 A0 O' h#if 0
. L3 H' }1 `) {7 u; C: G& O5 U) ?4 E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 c' k2 o+ \ S$ `3 M& H2 X f
if (ret)
+ l9 |8 z; R$ Z2 o+ N pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. E6 U$ z7 E9 d A5 X6 }5 X4 k "%d\n", ret);* v1 ~) N8 l% D2 ?( h
#endif
; p& J7 O* z( s ret = platform_device_register(&da850_evm_tl_leds_device);: U8 p8 X/ o$ l
if (ret)& L5 F+ q$ A/ _; G, U5 r3 I
pr_warning("Could not register som GPIO expander LEDS");
9 S H g, ]' ]/ i4 |# g else
3 t( f& m ~. G( P" \! ^ printk(KERN_INFO "LED register sucessful!\n");
" Y9 c8 J/ J5 X u6 {- {
1 \' O0 \* K' U" D' j% C- E return ret;9 H8 v8 q( C6 D6 R9 X/ O9 ^$ L
}
6 K* f+ d! b3 _3 ]4 f6 V6 d' Y9 L3 @; Z1 B) E1 E
static void __exit led_platform_exit(void)
& E8 E. C. O. E{# s+ n( M! l9 K8 X6 h S
platform_device_unregister(&da850_evm_tl_leds_device);
! K$ X& J: d7 J2 C, k" o3 e7 ]8 v
printk(KERN_INFO "LED unregister!\n");
* l, h. i: b8 y2 g6 X: E}
6 {! ^* ~2 `, j: G7 b1 [
- E8 _' A9 K% c- amodule_init(led_platform_init);3 I8 ]+ K# X7 e* [% C& H7 Z
module_exit(led_platform_exit);
" w( T/ c0 U: _9 W6 x" v* c$ o3 o8 `. S7 P N( Q" M, ~; z; a
MODULE_DESCRIPTION("Led platform driver");
! ^3 { Z. e! C$ mMODULE_AUTHOR("Tronlong");
6 x- V" R6 K6 v% J2 K) p( A. IMODULE_LICENSE("GPL");
! P& ]7 _$ O! o9 `3 T
s. ?" L% W7 J! R |
|